graphitemaster / incbin

Include binary files in C/C++
The Unlicense
941 stars 90 forks source link

Windows gets super moany with incbin.c #10

Closed IngwiePhoenix closed 9 years ago

IngwiePhoenix commented 9 years ago

I just tried to compile incbin.c on my 32bit Win7 maschine and it went berserk about missing semicolons and such. Weirdly, renaming the file to incbin.cpp (tricking cl into C++ mode) fixed the issue. Would be nice if you could look into this.

graphitemaster commented 9 years ago

That's odd. I have no Windows environment to test this on. Can you give me the output of the compiler?

graphitemaster commented 9 years ago

I converted the code to C90 code. This should fix issues on MSVC

IngwiePhoenix commented 9 years ago

I would - but its all German. :)

The updated version works, except for two things:

IngwiePhoenix commented 9 years ago

I tried to cheat by using /D snprintf=_snprintf...but then I got the "Cant open file" error and I have a slight feeling that is due to my...er...fix.

Here is what I found on snprintf: http://stackoverflow.com/questions/3976306/using-snprintf-in-a-cross-platform-application

graphitemaster commented 9 years ago

Fixed

IngwiePhoenix commented 9 years ago

Works!

I also found news on the PATH_MAX macro. A simple ifdef should totally do.

http://bytes.com/topic/c/answers/215365-path_max

So I suggest:

#ifndef PATH_MAX
#define PATH_MAX 255
#endif
IngwiePhoenix commented 9 years ago

Turns out its 1024 on my mac. Huh. Who ever needs such long paths though...