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

-std=c99 prevents library build on MinGW #13

Closed
ghost opened this issue Jun 9, 2016 · 1 comment
Closed

-std=c99 prevents library build on MinGW #13

ghost opened this issue Jun 9, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 9, 2016

I found that there is used by default GCC option -std=c99 and this option causes automatic definition of __STRICT_ANSI__ macro.
Because in MinGW some typedefs are protected by using this macro then they are not visible and library cannot be compiled i.e.:
#ifndef __STRICT_ANSI__
typedef __int64 off64_t;
#endif /* __STRICT_ANSI__ */

I try to define C_FLAGS in CMake configuration but user C_FLAGS is put before predefined one and then I cannot override them.
After I changed CMAKE_C_FLAGS in the CMakeLists.txt to:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
then everything build without problems.

cmake 5.5.2
mingw32-gcc 3.9.3.-1

$ mingw32-make cbor
[ 7%] Building C object src/CMakeFiles/cbor.dir/cbor.c.obj
In file included from c:\mingw\include\unistd.h:36:0,
from C:\tmp\libcbor-0.4.0\src\cbor.c:245:
c:\mingw\include\io.h:301:14: error: unknown type name 'off64_t'
__CRT_INLINE off64_t lseek64 (int, off64_t, int);
^
c:\mingw\include\io.h:301:36: error: unknown type name 'off64_t'
__CRT_INLINE off64_t lseek64 (int, off64_t, int);
^
c:\mingw\include\io.h:302:14: error: unknown type name 'off64_t'
__CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence) {
^
c:\mingw\include\io.h:302:39: error: unknown type name 'off64_t'
__CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence) {
^
In file included from C:\tmp\libcbor-0.4.0\src\cbor.c:245:0:
c:\mingw\include\unistd.h:65:20: error: unknown type name 'off_t'
int ftruncate(int, off_t);
^
src\CMakeFiles\cbor.dir\build.make:62: recipe for target 'src/CMakeFiles/cbor.dir/cbor.c.obj' failed
mingw32-make[3]: *** [src/CMakeFiles/cbor.dir/cbor.c.obj] Error 1
CMakeFiles\Makefile2:1037: recipe for target 'src/CMakeFiles/cbor.dir/all' failed
mingw32-make[2]: *** [src/CMakeFiles/cbor.dir/all] Error 2
CMakeFiles\Makefile2:1049: recipe for target 'src/CMakeFiles/cbor.dir/rule' failed
mingw32-make[1]: *** [src/CMakeFiles/cbor.dir/rule] Error 2
Makefile:571: recipe for target 'cbor' failed
mingw32-make: *** [cbor] Error 2

@PJK
Copy link
Owner

PJK commented Jan 1, 2017

Hi, thanks for reporting, will be fixed in #45

@PJK PJK closed this as completed in #45 Jan 1, 2017
PJK added a commit that referenced this issue Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant