Thanks Reid.
I tried it before and it actually works in this simple case.
The problem is that I have I big project with about 10000 files which
is portable and which compiles fine on many platforms
(win,linux,bsd,osx,android) with many compilers.
Before -fms-extensions I had a few errors in only one file
(which i can solve with a few #ifdef tricks).
After I put globaly - CFLAGS +=-fms-extensions in my make file , I get
houndreds of errors in connection with intrinsics.
Like :
../intrin-impl.h:960:10: error: definition of builtin function
'_InterlockedExchangeAdd'
__LONG32 _InterlockedExchangeAdd(__LONG32 volatile *Addend, __LONG32 Value)
{
...
Of course I can make bigger changes in my build system or in my header
files.
But I think that main idea is that we will have on windows two clang
compilers.
One msvc compatible (name ,abi, parameters ...) which will be replacement
for msvc compiler and
other mingw (gcc) compatible.
There are thousands of prejects which compile fine with gcc (mingw).
It would be a nice if they compile out of a box with clang (with maybe some
additional attribute).
We already define __declspec for mingw compatibility, so adding the ccs seems reasonable.
I’m curious if you can fix most of your errors with -fms-extensions by dropping your intrin-impl.h header and including clang’s intrin.h instead. You’ll have to hack out the _MSC_VER ifdef there. If that works, it might be worth making clang’s intrin.h header available when targeting mingw.
In file included from ../../../png.c:14:
In file included from ../../../pngpriv.h:462:
In file included from
C:/msys32/mingw32/bin/../i686-w64-mingw32/include\windows.h:69:
In file included from
C:/msys32/mingw32/bin/../i686-w64-mingw32/include\windef.h:8:
In file included from
C:/msys32/mingw32/bin/../i686-w64-mingw32/include\minwindef.h:146:
In file included from
C:/msys32/mingw32/bin/../i686-w64-mingw32/include\winnt.h:26:
C:/msys32/mingw32/bin/../i686-w64-mingw32/include\psdk_inc/intrin-impl.h:960:10:
error: definition of builtin function
'_InterlockedExchangeAdd'
__LONG32 _InterlockedExchangeAdd(__LONG32 volatile *Addend, __LONG32 Value)
{
As you see intrin-impl.h is included from winnt.h
#define __INTRINSIC_GROUP_WINNT /* only define the intrinsics in this file
*/ #include <psdk_inc/intrin-impl.h>
I also did a little hack changing psdk/intrin-impl to intrin.h in winnt.h
and here is result:
clang -I. -I../../../../../../include -Wmissing-braces -Wreturn-type
-Wformat -Wimplicit-int -Wimplicit-function-declaration -O3 -DUNICODE
-IG:/HRB_SVN/SRC-GIT/src/3rd/zlib -DPNG_NO_STDIO
-IC:/msys32/mingw32/lib/clang/3.5.0/include -fms-extensions -opng.o -c
../../../png.c
In file included from ../../../png.c:14:
In file included from ../../../pngpriv.h:462:
In file included from
C:\msys32\mingw32\bin/../i686-w64-mingw32/include\windows.h:69:
In file included from
C:\msys32\mingw32\bin/../i686-w64-mingw32/include\windef.h:8:
In file included from
C:\msys32\mingw32\bin/../i686-w64-mingw32/include\minwindef.h:146:
In file included from
C:\msys32\mingw32\bin/../i686-w64-mingw32/include\winnt.h:27:
C:/msys32/mingw32/lib/clang/3.5.0/include/intrin.h:294:13: error:
conflicting types for '_setjmp'
int __cdecl _setjmp(jmp_buf);
^
C:\msys32\mingw32\bin/../i686-w64-mingw32/include\setjmp.h:164:63: note:
previous declaration is here
int __cdecl __attribute__ ((__nothrow__,__returns_twice__))
_setjmp(jmp_buf _Buf, void *_Ctx);
^
C:\msys32\mingw32\bin/../i686-w64-mingw32/include\setjmp.h:164:63: note:
previous declaration is here
int __cdecl __attribute__ ((__nothrow__,__returns_twice__))
_setjmp(jmp_buf _Buf, void *_Ctx);
^
In file included from ../../../png.c:14:
In file included from ../../../pngpriv.h:462:
In file included from
C:\msys32\mingw32\bin/../i686-w64-mingw32/include\windows.h:70:
In file included from
C:\msys32\mingw32\bin/../i686-w64-mingw32/include\winbase.h:45:
C:\msys32\mingw32\bin/../i686-w64-mingw32/include\psdk_inc/intrin-impl.h:849:13:
error: redefinition of '__stosb'
__buildstos(__stosb, unsigned char, "b")
....
IMHO the simplest solution would be if clang/gcc preprocessor translates
_cdecl,_stdcall,... to
__attribute__((...)) .
After this commit I can compile all my files and create static libs.
There is still a problem creating shared libs (with *clang -shared*).
Any solution?
Cannot export _hello: symbol not found
collect2.exe: error: ld returned 1 exit status
I intentionaly use gcc -shared to show that the problem is in clang
compiler (32bit) producing a wrong test.o,
while 64bti version is ok ( wheter I use gcc -shared or clang -shared and
later link test.dll to main.c)