Trouble running Allegro examples from Github. Visual Studio build errors
piskypom

I'm trying to run the ex_mouse_events.c example. Previously I had no trouble running the ex_keyboard_events.c example. I only have a few days experience with Allegro so please inform me with the information I need to provide to get further help.

As it stands, here is the debug output:

#SelectExpand
11>------ Build started: Project: Allegro_Mouse_Example, Configuration: Debug Win32 ------ 21>common.c 31>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(12): error C2146: syntax error: missing ')' before identifier 'wait_for_user' 41>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(12): error C2061: syntax error: identifier 'wait_for_user' 51>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(12): error C2059: syntax error: ';' 61>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(12): error C2059: syntax error: ')' 71>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(95): warning C4013: 'exit' undefined; assuming extern returning int 81>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(106): error C2146: syntax error: missing ')' before identifier 'wait_for_user' 91>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(106): error C2061: syntax error: identifier 'wait_for_user' 101>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(106): error C2059: syntax error: ';' 111>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(106): error C2059: syntax error: ')' 121>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(107): error C2449: found '{' at file scope (missing function header?) 131>i:\documents\scripts\c++\projects\allegro_mouse_example\allegro_mouse_example\common.c(109): error C2059: syntax error: '}' 141>Done building project "Allegro_Mouse_Example.vcxproj" -- FAILED. 15========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The example file is here: Github - ex_mouse_events.c

I have common.c included in the source code and in the project solution. Any thoughts? Thanks!

Edgar Reynaldo

It doesn't know what a "bool" is, that's why it fails. 'bool' is C99 or C++. Change the standard you're using to compile the code. I don't use MSVS so you'll have to figure it out on your own.

NiteHackr

Yeah, there are no problems compiling this with a GNU compiler like MinGW (comes with Code::Blocks). I compiled everything up using Code::Blocks. In CMake I configured it to create Code::Blocks makefiles with MinGW, then you simply load it into the IDE and compile. Too easy.

I also added in an option to compile my own version with the -std=gnu11 switch so the C coded compiled with the C11 standard, you could try -std=c99. I don't know if MSVC has an option to compile C with a certain standard. You may need to either switch compilers, or update your MSVC compiler you are currently using.

My guess is that you are using an older version of MSVC. They do not fully support C, but they have improved and support much of the important, more modern features of C (though technically, it still compiles using a C++ compiler). Older versions of MSVC only supported C89/90. The latest version supports the features of C99/C11 which are compatible with the latest C++ versions, so it should definitely compile if you have a newer version of MSVC installed.

piskypom

Yeah. You were right. It was "bool". I don't know how to change the compile code. I just removed all the code calling common.c and was able to figure out what I needed to know after that.

Thank you guys. I apologize for the late reply.

NiteHackr

Which version of MSVC are you using?

piskypom

I'm running Visual Studio Community 2017 v15.5.6.

Thread #617300. Printed from Allegro.cc