diff --git a/emcc.py b/emcc.py index b65bdda854ae4..2c014e2c31d4c 100755 --- a/emcc.py +++ b/emcc.py @@ -3812,7 +3812,11 @@ def parse_string_list(text): return parse_string_list(text) try: - return int(text) + if text.startswith('0x'): + base = 16 + else: + base = 10 + return int(text, base) except ValueError: return parse_string_value(text) diff --git a/tests/test_other.py b/tests/test_other.py index c2f07c70d202b..ae997216f33b7 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -6556,6 +6556,11 @@ def test_dash_s_no_space(self): err = self.expect_fail([EMXX, test_file('hello_world.cpp'), '-sEXPORTED_FUNCTIONS=foo']) self.assertContained('error: undefined exported symbol: "foo"', err) + def test_dash_s_hex(self): + self.run_process([EMCC, test_file('hello_world.c'), '-nostdlib', '-sERROR_ON_UNDEFINED_SYMBOLS=0']) + # Ensure that 0x0 is parsed as a zero and not as the string '0x0'. + self.run_process([EMCC, test_file('hello_world.c'), '-nostdlib', '-sERROR_ON_UNDEFINED_SYMBOLS=0x0']) + def test_zeroinit(self): create_file('src.c', r''' #include