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:
17
module.cpp
17
module.cpp
@@ -1343,14 +1343,6 @@ Module::writeHeader(const char *fn) {
|
|||||||
lEmitEnumDecls(exportedEnumTypes, f);
|
lEmitEnumDecls(exportedEnumTypes, f);
|
||||||
lEmitStructDecls(exportedStructTypes, 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...
|
// emit function declarations for exported stuff...
|
||||||
if (exportedFuncs.size() > 0) {
|
if (exportedFuncs.size() > 0) {
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
@@ -1372,6 +1364,15 @@ Module::writeHeader(const char *fn) {
|
|||||||
// end namespace
|
// end namespace
|
||||||
fprintf(f, "\n#ifdef __cplusplus\n}\n#endif // __cplusplus\n");
|
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
|
// end guard
|
||||||
fprintf(f, "\n#endif // %s\n", guard.c_str());
|
fprintf(f, "\n#endif // %s\n", guard.c_str());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user