emscripten-core / emscripten-core/emscripten

compile time errors when including header file emscripten.h from $ENV{EMSDK}/upstream/emscripten/cache/sysroot/include/emscripten

Open
#22,948 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

emcc - v3.1.71

including header file emscripten.h compiles successfully but it causes compile time error
which hinders code completion such as ```emscripten_set_main_loop```.

cmake config
```
target_include_directories(
${CMAKE_PROJECT_NAME}
PUBLIC
$ENV{EMSDK}/upstream/emscripten/cache/sysroot/include/emscripten
)
```
for some unknown reason cmake can't include this specific path
```
$ENV{EMSDK}/upstream/emscripten/cache/sysroot/include
```
so i use
```
$ENV{EMSDK}/upstream/emscripten/cache/sysroot/include/emscripten
```
instead.

#### first error
```In included file: 'emscripten/em_macros.h' file not found```.
solution
```
// em_js.h
#include em_macros.h
```

#### second new error
```In included file: typedef redefinition with different types ('struct _iobuf' vs 'struct _IO_FILE') [redefinition_different_typedef]```.

```
// emscripten.h
struct _IO_FILE;
typedef struct _IO_FILE FILE;

char *emscripten_get_preloaded_image_data(const char *path, int *w, int *h);
char *emscripten_get_preloaded_image_data_from_FILE(FILE *file, int *w, int *h);
```
my naive solution
```
// emscripten.h
struct _IO_FILE;

char *emscripten_get_preloaded_image_data(const char *path, int *w, int *h);
char *emscripten_get_preloaded_image_data_from_FILE(_IO_FILE *file, int *w, int *h);

```

after the following changes compile time error gone and code completion now works.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.