Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: expected expression before ‘?’ #591

Closed
aarree opened this issue Mar 9, 2023 · 4 comments
Closed

Error: expected expression before ‘?’ #591

aarree opened this issue Mar 9, 2023 · 4 comments

Comments

@aarree
Copy link

aarree commented Mar 9, 2023

Hi,
I am new to haxe and I've got the following errors while trying to compile the Hello World example.
OS; Ubuntu (WSL)
compile.hxml

-cp src
-hl out/main.c
-lib hlsdl
-lib heaps
-main Main
-debug

gcc command

gcc -o myapp out/main.c -I ./out -lhl -L /usr/local/lib/*.hdll

Error

      | 
      |sdl_Window_set_displayMode
./out/hl/functions.c:8687: error: ‘sdl_win_display_handle’ undeclared here (not in a function)
In file included from out/main.c:40:
./out/sdl/Window.c: In function ‘sdl_Window_set_displayMode’:
./out/sdl/Window.c:272:7: error: expected expression before ‘?’ token
  272 |  r2 = ?sdl_win_set_display_mode(r3,r4,r5,r8);
      |       ^
./out/sdl/Window.c:272:8: warning: implicit declaration of function ‘sdl_win_set_display_mode’; did you mean ‘sdl_Window_set_displayMode’? [-Wimplicit-function-declaration]
  272 |  r2 = ?sdl_win_set_display_mode(r3,r4,r5,r8);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
      |        sdl_Window_set_displayMode
./out/sdl/Window.c: In function ‘sdl_Window_get_currentMonitor’:
./out/sdl/Window.c:442:7: error: expected expression before ‘?’ token
  442 |  r1 = ?sdl_win_display_handle(r2);
      |       ^
./out/sdl/Window.c:442:8: warning: implicit declaration of function ‘sdl_win_display_handle’ [-Wimplicit-function-declaration]
  442 |  r1 = ?sdl_win_display_handle(r2);
      |        ^~~~~~~~~~~~~~~~~~~~~~
./out/sdl/Window.c:442:5: warning: assignment to ‘int’ from ‘void **’ makes integer from pointer without a cast [-Wint-conversion]
  442 |  r1 = ?sdl_win_display_handle(r2);
      |     ^
In file included from out/main.c:205:
./out/h3d/impl/GlDriver.c: In function ‘h3d_impl_GlDriver_uploadTexturePixels’:
./out/h3d/impl/GlDriver.c:3914:2: error: expected expression before ‘?’ token
 3914 |  ?sdl_gl_compressed_tex_sub_image3d(r6,r3,r26,r28,r4,r30,r31,r32,r33,r13,r25);
      |  ^
./out/h3d/impl/GlDriver.c:3914:3: warning: implicit declaration of function ‘sdl_gl_compressed_tex_sub_image3d’; did you mean ‘sdl_gl_compressed_tex_image3d’? [-Wimplicit-function-declaration]
 3914 |  ?sdl_gl_compressed_tex_sub_image3d(r6,r3,r26,r28,r4,r30,r31,r32,r33,r13,r25);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |   sdl_gl_compressed_tex_image3d
./out/h3d/impl/GlDriver.c:3942:2: error: expected expression before ‘?’ token
 3942 |  ?sdl_gl_tex_sub_image3d(r6,r3,r26,r28,r4,r30,r31,r32,r33,r34,r25);
      |  ^
./out/h3d/impl/GlDriver.c:3942:3: warning: implicit declaration of function ‘sdl_gl_tex_sub_image3d’; did you mean ‘sdl_gl_tex_image3d’? [-Wimplicit-function-declaration]
 3942 |  ?sdl_gl_tex_sub_image3d(r6,r3,r26,r28,r4,r30,r31,r32,r33,r34,r25);
      |   ^~~~~~~~~~~~~~~~~~~~~~
      |   sdl_gl_tex_image3d
In file included from out/main.c:430:
./out/sdl/Sdl.c: In function ‘sdl_Sdl_getScreenWidth’:
./out/sdl/Sdl.c:225:7: error: expected expression before ‘?’ token
  225 |  r1 = ?sdl_get_screen_width();
      |       ^
./out/sdl/Sdl.c:225:8: warning: implicit declaration of function ‘sdl_get_screen_width’; did you mean ‘sdl_Sdl_getScreenWidth’? [-Wimplicit-function-declaration]
  225 |  r1 = ?sdl_get_screen_width();
      |        ^~~~~~~~~~~~~~~~~~~~
      |        sdl_Sdl_getScreenWidth
./out/sdl/Sdl.c:225:5: warning: assignment to ‘int’ from ‘void **’ makes integer from pointer without a cast [-Wint-conversion]
  225 |  r1 = ?sdl_get_screen_width();
      |     ^
./out/sdl/Sdl.c:230:7: error: expected expression before ‘?’ token
  230 |  r1 = ?sdl_get_screen_width_of_window(r2);
      |       ^
./out/sdl/Sdl.c:230:8: warning: implicit declaration of function ‘sdl_get_screen_width_of_window’ [-Wimplicit-function-declaration]
  230 |  r1 = ?sdl_get_screen_width_of_window(r2);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./out/sdl/Sdl.c:230:5: warning: assignment to ‘int’ from ‘void **’ makes integer from pointer without a cast [-Wint-conversion]
  230 |  r1 = ?sdl_get_screen_width_of_window(r2);
      |     ^
./out/sdl/Sdl.c: In function ‘sdl_Sdl_getScreenHeight’:
./out/sdl/Sdl.c:238:7: error: expected expression before ‘?’ token
  238 |  r1 = ?sdl_get_screen_height();
      |       ^
./out/sdl/Sdl.c:238:8: warning: implicit declaration of function ‘sdl_get_screen_height’; did you mean ‘sdl_Sdl_getScreenHeight’? [-Wimplicit-function-declaration]
  238 |  r1 = ?sdl_get_screen_height();
      |        ^~~~~~~~~~~~~~~~~~~~~
      |        sdl_Sdl_getScreenHeight
./out/sdl/Sdl.c:238:5: warning: assignment to ‘int’ from ‘void **’ makes integer from pointer without a cast [-Wint-conversion]
  238 |  r1 = ?sdl_get_screen_height();
      |     ^
./out/sdl/Sdl.c:243:7: error: expected expression before ‘?’ token
  243 |  r1 = ?sdl_get_screen_height_of_window(r2);
      |       ^
./out/sdl/Sdl.c:243:8: warning: implicit declaration of function ‘sdl_get_screen_height_of_window’ [-Wimplicit-function-declaration]
  243 |  r1 = ?sdl_get_screen_height_of_window(r2);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./out/sdl/Sdl.c:243:5: warning: assignment to ‘int’ from ‘void **’ makes integer from pointer without a cast [-Wint-conversion]
  243 |  r1 = ?sdl_get_screen_height_of_window(r2);
      |     ^
./out/sdl/Sdl.c: In function ‘sdl_Sdl_getDisplayModes’:
./out/sdl/Sdl.c:271:7: error: expected expression before ‘?’ token
  271 |  r1 = ?sdl_get_display_modes(r2);
      |       ^
./out/sdl/Sdl.c:271:8: warning: implicit declaration of function ‘sdl_get_display_modes’; did you mean ‘sdl_Sdl_getDisplayModes’? [-Wimplicit-function-declaration]
  271 |  r1 = ?sdl_get_display_modes(r2);
      |        ^~~~~~~~~~~~~~~~~~~~~
      |        sdl_Sdl_getDisplayModes
./out/sdl/Sdl.c:271:5: warning: assignment to ‘varray *’ from incompatible pointer type ‘void **’ [-Wincompatible-pointer-types]
  271 |  r1 = ?sdl_get_display_modes(r2);
      |     ^
./out/sdl/Sdl.c: In function ‘sdl_Sdl_getCurrentDisplayMode’:
./out/sdl/Sdl.c:308:7: error: expected expression before ‘?’ token
  308 |  r3 = ?sdl_get_current_display_mode(r4,r2);
      |       ^
./out/sdl/Sdl.c:308:8: warning: implicit declaration of function ‘sdl_get_current_display_mode’ [-Wimplicit-function-declaration]
  308 |  r3 = ?sdl_get_current_display_mode(r4,r2);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./out/sdl/Sdl.c:308:5: warning: assignment to ‘vdynamic *’ from incompatible pointer type ‘void **’ [-Wincompatible-pointer-types]
  308 |  r3 = ?sdl_get_current_display_mode(r4,r2);
      |     ^
./out/sdl/Sdl.c: In function ‘sdl_Sdl_getDisplays’:
./out/sdl/Sdl.c:323:7: error: expected expression before ‘?’ token
  323 |  r0 = ?sdl_get_displays();
      |       ^
./out/sdl/Sdl.c:323:8: warning: implicit declaration of function ‘sdl_get_displays’; did you mean ‘sdl_Sdl_getDisplays’? [-Wimplicit-function-declaration]
  323 |  r0 = ?sdl_get_displays();
      |        ^~~~~~~~~~~~~~~~
      |        sdl_Sdl_getDisplays
./out/sdl/Sdl.c:323:5: warning: assignment to ‘varray *’ from incompatible pointer type ‘void **’ [-Wincompatible-pointer-types]
  323 |  r0 = ?sdl_get_displays();
      |     ^
./out/sdl/Sdl.c:337:7: error: expected expression before ‘?’ token
  337 |  r1 = ?sdl_get_displays();
      |       ^
./out/sdl/Sdl.c:337:5: warning: assignment to ‘varray *’ from incompatible pointer type ‘void **’ [-Wincompatible-pointer-types]
  337 |  r1 = ?sdl_get_displays();
      |     ^
In file included from out/main.c:430:
./out/sdl/Sdl.c: In function ‘sdl_Sdl_setClipboardText’:
./out/sdl/Sdl.c:443:7: error: expected expression before ‘?’ token
  443 |  r1 = ?sdl_set_clipboard_text(r2);
      |       ^
./out/sdl/Sdl.c:443:8: warning: implicit declaration of function ‘sdl_set_clipboard_text’; did you mean ‘sdl_Sdl_setClipboardText’? [-Wimplicit-function-declaration]
  443 |  r1 = ?sdl_set_clipboard_text(r2);
      |        ^~~~~~~~~~~~~~~~~~~~~~
      |        sdl_Sdl_setClipboardText
./out/sdl/Sdl.c: In function ‘sdl_Sdl_getClipboardText’:
./out/sdl/Sdl.c:450:7: error: expected expression before ‘?’ token
  450 |  r0 = ?sdl_get_clipboard_text();
      |       ^
./out/sdl/Sdl.c:450:8: warning: implicit declaration of function ‘sdl_get_clipboard_text’; did you mean ‘sdl_Sdl_getClipboardText’? [-Wimplicit-function-declaration]
  450 |  r0 = ?sdl_get_clipboard_text();
      |        ^~~~~~~~~~~~~~~~~~~~~~
      |        sdl_Sdl_getClipboardText
./out/sdl/Sdl.c:450:5: warning: assignment to ‘vbyte *’ {aka ‘unsigned char *’} from incompatible pointer type ‘void **’ [-Wincompatible-pointer-types]
  450 |  r0 = ?sdl_get_clipboard_text();
@Aurel300
Copy link
Member

Which version of Haxe are you using? I'm guessing it's an old one: the ? syntax for optional native HashLink dependencies hasn't always been supported.

@aarree
Copy link
Author

aarree commented Mar 10, 2023

Hey @Aurel300,
Thanks for getting back!
I am running a haxe:4.2.5 docker-container and build haschlink from git.
If i am not mistaken this should result in the newest Haxe and Hashlink versions.

Dockerfile looks like this.

FROM haxe:4.2.5
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# install dependencies
COPY *.hxml /usr/src/app/
RUN yes | haxelib install all

# compile the project
COPY . /usr/src/app

RUN apt-get update 
RUN apt-get install -y --no-install-recommends \
    g++ \
    libmbedtls-dev \
    libopenal-dev \
    libpng-dev \
    libsdl2-dev \
    libturbojpeg-dev \
    libuv1-dev \
    libvorbis-dev \
    libsqlite3-dev \
    make
    
RUN haxelib install hlsdl && \
    haxelib git heaps https://github.com/HeapsIO/heaps.git && \
    haxelib git hashlink https://github.com/HaxeFoundation/hashlink.git master other/haxelib/

RUN git clone https://github.com/HaxeFoundation/hashlink
RUN cd hashlink && make 
RUN cd hashlink && make install

RUN haxe compile.hxml

RUN dir
RUN cp hashlink/*.hdll /usr/src/app/.
# run the output when the container starts
RUN gcc -O3 -o helloWorld -std=c11 -I out out/main.c sdl.hdll ui.hdll fmt.hdll openal.hdll ui.hdll uv.hdll -lhl

# docker build -t my-haxe-app .
# docker run -it my-haxe-app

@tobil4sk
Copy link
Member

The fix is yet to come in an official Haxe release, so you'll have to use a nightly build of Haxe for the Hashlink/C code to generate properly.
HaxeFoundation/haxe#10509

@aarree
Copy link
Author

aarree commented Mar 14, 2023

Thanks!
Could get it to work with the haxe_rc.

@aarree aarree closed this as completed Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants