When emitting header files, put 'extern' declarations of globals used

in ispc code outside of the ispc namespace.  Fixes issue #64.
This commit is contained in:
Matt Pharr
2011-08-26 10:03:06 -07:00
parent f22b3a25bd
commit a322398c62

View File

@@ -1343,14 +1343,6 @@ Module::writeHeader(const char *fn) {
lEmitEnumDecls(exportedEnumTypes, f);
lEmitStructDecls(exportedStructTypes, f);
// emit externs for globals
if (externGlobals.size() > 0) {
fprintf(f, "///////////////////////////////////////////////////////////////////////////\n");
fprintf(f, "// Globals declared \"extern\" from ispc code\n");
fprintf(f, "///////////////////////////////////////////////////////////////////////////\n");
lPrintExternGlobals(f, externGlobals);
}
// emit function declarations for exported stuff...
if (exportedFuncs.size() > 0) {
fprintf(f, "\n");
@@ -1372,6 +1364,15 @@ Module::writeHeader(const char *fn) {
// end namespace
fprintf(f, "\n#ifdef __cplusplus\n}\n#endif // __cplusplus\n");
// and only now emit externs for globals, outside of the ispc namespace
if (externGlobals.size() > 0) {
fprintf(f, "\n");
fprintf(f, "///////////////////////////////////////////////////////////////////////////\n");
fprintf(f, "// Globals declared \"extern\" from ispc code\n");
fprintf(f, "///////////////////////////////////////////////////////////////////////////\n");
lPrintExternGlobals(f, externGlobals);
}
// end guard
fprintf(f, "\n#endif // %s\n", guard.c_str());