How do I compile a c99-to-c89 converter with clang?

I'm trying to compile ffmpeg on windows for VisualStudio and one of the steps is to compile c99-to-c89 code with clang according to this post. I was able to create clang.exe, but how do I compile the c99-to-c89 code?

I changed the makefile a bit in c99-to-c89 so the variable CC

now points to the compiler clang.exe and not cl.exe

EXT=.exe

all: c99conv$(EXT) c99wrap$(EXT)

CLANGDIR=C:/build
CC=C:/build/bin/Release/clang.exe
CFLAGS=-nologo -Z7 -D_CRT_SECURE_NO_WARNINGS=1 -Dpopen=_popen -Dunlink=_unlink -Dstrdup=_strdup -Dsnprintf=_snprintf -I. -I$(CLANGDIR)/tools/clang/include
LDFLAGS=-nologo -Z7 $(CLANGDIR)/lib/Release/libclang.lib

clean:
    rm -f c99conv$(EXT) c99wrap$(EXT) convert.o compilewrap.o
    rm -f unit.c.c unit2.c.c

test1: c99conv$(EXT)
    $(CC) -P unit.c -Fiunit.prev.c
    ./c99conv unit.prev.c unit.post.c
    diff -u unit.{prev,post}.c

test2: c99conv$(EXT)
    $(CC) -P unit2.c -Fiunit2.prev.c
    ./c99conv unit2.prev.c unit2.post.c
    diff -u unit2.{prev,post}.c

test3: c99conv$(EXT)
    $(CC) $(CFLAGS) -P -Ficonvert.prev.c convert.c
    ./c99conv convert.prev.c convert.post.c
    diff -u convert.{prev,post}.c

c99conv$(EXT): convert.o
    $(CC) -Fe$@ $< $(LDFLAGS) $(LIBS)

c99wrap$(EXT): compilewrap.o
    $(CC) -Fe$@ $< $(LDFLAGS)

%.o: %.c
    $(CC) $(CFLAGS) -Fo$@ -c $<

      

but when i run the command make

i get clang: error: unsupported use of internal gcc -Z option '-Z7'

. I think the problem is in CFLAGS

and LDFLAGS

, but I don't know how to fix it because there is a lack of knowledge in the makefile and clang.

0


source to share


2 answers


If anyone is still need of libav guys gave me a link this to download binary files c99conv.exe

, c99wrap.exe

,makedef



+3


source


c99conv wust must be compiled with the msvc compiler, but it uses libraries from LLVM. Actualy, the converter uses clang as its C99 parser sources.

Therefore clang needs to be compiled with MSVC (because MSVC will link libclang with c99conv).

So, just run the building instructions from the article you link.



  • Run visual studio studio command.
  • Start the msys shell from mingw.
  • Tune Makefile.w32 for your environment
  • Compile c99conv with Makefile.w32

make -f Makefile.w32

      

+1


source







All Articles