f1nalspace / final_game_tech

Game related libraries written in C/C++ written by T. Spaete
MIT License
177 stars 10 forks source link

building with "g++" and "clang++" (develop version - errors) #160

Open mladinox opened 2 months ago

mladinox commented 2 months ago
  1. in "g++", persists the fatal error:

--> g++ -Wall -Os -o ./helloword ./helloword.cpp -lpthread -ldl In file included from ./helloword.cpp:2: ./final_platform_layer.h:2311:51: error: no match for ‘operator=’ (operand types are ‘fplVersionInfo’ and ‘’) 2311 | # define fplm_StructInit(type, ...) {__VA_ARGS}

  1. in "clang++", first error pass, but other fatal error throws:

--> clang++ -Wall -Os -o ./helloword ./helloword.cpp -lpthread -ldl In file included from ./helloword.cpp:2: ./final_platform_layer.h:16732:71: error: non-constant-expression cannot be narrowed from type 'int' to 'uint32_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing] windowState->lastWindowStateInfo.size = fplStructInit(fplWindowSize, windowX, windowY); ^~~

  1. helloword.cpp

    define FPL_IMPLEMENTATION

    include "final_platform_layer.h"

int main(int argc, char **argv) { int result; // if (fplPlatformInit(fplInitFlags_Console)) // { fplConsoleOut("Hello World!"); fplPlatformRelease(); result = 0; // } else { // result = -1; // } return(result); }

f1nalspace commented 2 months ago

I booted up my ubuntu dev machine and compiled the "FPL_C" from the demos, using the following command: g++ -Wall -Os -o ../bin/FPL_C/Linux-x64-debug/FPL_C ./fpl_c.c Without explicitly setting PThread and DL.

And it compiled just fine, but there was some warnings - but nothing that is a problem.

Which version you GCC/G++ do you use?

I use:

g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, which worked fine.

Also please try to compile one of the demos, FPL_C or FPL_Audio or FPL_OpenGL. The Makefile's may need some adjustments, i haven't touched those in years.

Thanks

f1nalspace commented 2 months ago

Never mind, i could reproduce the error by simply using your "helloworld" example. I will fix this after i get back from holiday.

f1nalspace commented 2 months ago

Btw: I did two commits, but it only solved one issue. The weird fplVersionInfo initializer list error is still there in clang, but this should work - all 5 fields are properly set. Maybe clang does not support initializer lists with fields like char[5] = "1"?