From 6e8af5038baaf94db440778e9a798cf8a8a616d7 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 8 Jul 2011 09:14:52 -0700 Subject: [PATCH] Fix issue #62: emit stdlib code as char array, not a string MSVC 2010 issues an error if given a string larger than 64k characters long. To work around this, the pre-processed stdlib.ispc code is now stored as an array of characters terminated with a NUL (i.e. the same thing in the end); MSVC is fine with arrays larger than 64k characters. --- builtins.cpp | 2 +- stdlib2cpp.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/builtins.cpp b/builtins.cpp index aabca575..d72bb371 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -625,7 +625,7 @@ DefineStdlib(SymbolTable *symbolTable, llvm::LLVMContext *ctx, llvm::Module *mod // If the user wants the standard library to be included, parse the // serialized version of the stdlib.ispc file to get its definitions // added. - extern const char *stdlib_code; + extern char stdlib_code[]; yy_scan_string(stdlib_code); yyparse(); } diff --git a/stdlib2cpp.py b/stdlib2cpp.py index c1b7bf1b..132f8257 100755 --- a/stdlib2cpp.py +++ b/stdlib2cpp.py @@ -2,10 +2,11 @@ import sys -print "const char *stdlib_code = " -for line in sys.stdin: - l=line.rstrip() - l=l.replace('"', '\\"') - print "\"" + l + "\\n\"" +print "char stdlib_code[] = { " -print ";" +for line in sys.stdin: + for c in line: + print ord(c) + print ", " + +print "0 };"