Ro5bert / avra

Assembler for the Atmel AVR microcontroller family
GNU General Public License v2.0
156 stars 40 forks source link

error: 'VERSION' undeclared (first use in this function) #22

Closed somefunAgba closed 4 years ago

somefunAgba commented 4 years ago

There is an error when building from source on Windows.

file.c:98:11: error: 'VERSION' undeclared (first use in this function) VERSION, basename, ctime(&pi->time)); file.c:98:11: _note: each undeclared identifier is reported only once for each function it appears in macro.c: In function 'expandmacro'

I was able to resolve this by adding the following to avra.h

#ifndef VERSION
#define VERSION "undefined"
#endif

Saw that the above was defined in avra.c. Placing it in avra.h solved the problem.

I guess it would be helpful for others, if this was rectified in the main code base.

Ro5bert commented 4 years ago

Hi,

Thanks for reporting this issue. VERSION should be filled in by a define during compilation. Currently, it looks like the makefiles rely on the default recipe for making object files from C files using the CFLAGS variable, which contains the necessary -DVERSION=..., but perhaps this assumption doesn't hold for the version of make you're using. (Either way, I don't like relying on the implicit rules, so this should probably be changed.) Could you specify what version of make you're using/how you are invoking make?

somefunAgba commented 4 years ago

I compiled directly on Windows without using the Makefile. . Instead of undefined, I was able to add the following to avra.h, so the version would show when running avra: .

ifndef VERSION

define VERSION "v1.4.2"

endif

. I am using the mingw variant of make. I also installed Gnu Make for Windows. After some frustrations with the errors 'make' was throwing even after changing the line: 'OS =linux' to 'OS =mingw'. I finally compiled directly without the Makefile, through Cmake bundled with the CLion IDE. . Guess it is not a problem for those on a Unix/Linux OS, but ensuring it works for native Windows will make it better. As done in the Makefile, I will add the version directly in the CMake file and upload it here later.

Ro5bert commented 4 years ago

I'm not sure what you mean by "[build] without using the Makefile". Did you manually invoke the compiler and linker? If so, that would explain the error with VERSION.

Currently, to build on a given OS x, you should execute make OS=x (unless x=linux, which is the default). You may also have to change your compiler: make OS=x CC=mycompiler. The supported OS's can be found in the src/makefiles directory as Makefile.x files. You mentioned trying OS=mingw, but that's not a supported OS; maybe try OS=mingw32, instead. The mingw32 makefile was recently reported as working.