aboutsummaryrefslogtreecommitdiff
path: root/emcc
diff options
context:
space:
mode:
Diffstat (limited to 'emcc')
-rwxr-xr-xemcc14
1 files changed, 13 insertions, 1 deletions
diff --git a/emcc b/emcc
index 73f12cda..f21feb1f 100755
--- a/emcc
+++ b/emcc
@@ -596,6 +596,10 @@ try:
keep_debug = False
bind = False
jcache = False
+ if use_cxx:
+ default_cxx_std = '-std=c++03' # Enforce a consistent C++ standard when compiling .cpp files, if user does not specify one on the cmdline.
+ else:
+ default_cxx_std = '' # Compiling C code with .c files, don't enforce a default C++ std.
def check_bad_eq(arg):
assert '=' not in arg, 'Invalid parameter (do not use "=" with "--" options)'
@@ -659,7 +663,11 @@ try:
keep_debug = True
elif newargs[i] == '--bind':
bind = True
- newargs[i] = '-std=c++11' # Force C++11 for embind code
+ newargs[i] = ''
+ if default_cxx_std:
+ default_cxx_std = '-std=c++11' # Force C++11 for embind code, but only if user has not explicitly overridden a standard.
+ elif newargs[i].startswith('-std='):
+ default_cxx_std = '' # User specified a standard to use, clear Emscripten from specifying it.
elif newargs[i].startswith('--embed-file'):
check_bad_eq(newargs[i])
embed_files.append(newargs[i+1])
@@ -717,6 +725,10 @@ try:
absolute_warning_shown = True
newargs = [ arg for arg in newargs if arg is not '' ]
+ # If user did not specify a default -std for C++ code, specify the emscripten default.
+ if default_cxx_std:
+ newargs = newargs + [default_cxx_std]
+
if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level]
if llvm_lto is None: llvm_lto = llvm_opts > 0
if closure is None: closure = 1 if opt_level >= 2 else 0