Index: src/SynTree/FunctionDecl.cc
===================================================================
--- src/SynTree/FunctionDecl.cc	(revision 0270824d417173d850d0b904d76e8e5873a6ec65)
+++ src/SynTree/FunctionDecl.cc	(revision 3fe34ae393b9647360e8310b11c0d6f9863d9062)
@@ -23,4 +23,6 @@
 #include "InitTweak/InitTweak.h"
 
+extern bool translation_unit_nomain;
+
 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, std::list< Attribute * > attributes )
 		: Parent( name, sc, linkage, attributes ), type( type ), statements( statements ) {
@@ -30,5 +32,5 @@
 	// because we want to replace the main even if it is inside an extern
 	if ( name == "main" ) {
-		set_linkage( LinkageSpec::Cforall );
+		set_linkage( translation_unit_nomain ? LinkageSpec::C : LinkageSpec::Cforall );
 	} // if
 }
