Skip to content

Commit 506052b

Browse files
authored
Warn about usage of deprecated EMSCRIPTEN macro. NFC (#26381)
This change is in preparation for removing the pre-defintion of this macro from the emcc driver.
1 parent 5c277a5 commit 506052b

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.
2020

2121
5.0.3 (in development)
2222
----------------------
23+
- Warn on usage of the deprecated `EMSCRIPTEN` macro (`__EMSCRIPTEN__` should
24+
be used instead). (#26381)
2325
- When building with `-sWASM_WORKERS` emscripten will no longer include pthread
2426
API stub functions. These stub functions where never designed to work under
2527
Wasm Workers, so its safer to error at link time if pthread APIs are used

system/include/emscripten/emscripten.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
#include "wget.h"
2929
#include "version.h"
3030

31+
#ifdef __EMSCRIPTEN__
32+
#ifndef EMSCRIPTEN
33+
#define EMSCRIPTEN
34+
#endif
35+
#pragma clang deprecated(EMSCRIPTEN, "use __EMSCRIPTEN__ instead")
36+
#endif
37+
3138
#ifdef __cplusplus
3239
extern "C" {
3340
#endif

test/test_other.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11292,6 +11292,17 @@ def test_error(pre):
1129211292
test_error('Module = { preRun: [] };')
1129311293
test_error('Module.preRun = [];')
1129411294

11295+
def test_EMSCRIPTEN_macro(self):
11296+
create_file('src.c', '''
11297+
#include <emscripten.h>
11298+
11299+
#ifdef EMSCRIPTEN
11300+
int foo;
11301+
#endif
11302+
''')
11303+
self.assert_fail([EMCC, '-Werror', 'src.c', '-c'], "'EMSCRIPTEN' has been marked as deprecated: use __EMSCRIPTEN__ instead")
11304+
self.assert_fail([EMCC, '-sSTRICT', '-Werror', 'src.c', '-c'], "'EMSCRIPTEN' has been marked as deprecated: use __EMSCRIPTEN__ instead")
11305+
1129511306
def test_EMSCRIPTEN_and_STRICT(self):
1129611307
# __EMSCRIPTEN__ is the proper define; we support EMSCRIPTEN for legacy
1129711308
# code, unless STRICT is enabled.

0 commit comments

Comments
 (0)