rcls / crap

Cvs Remote Access Program
GNU General Public License v3.0
46 stars 12 forks source link

Does not compile with C99 #14

Closed efalk closed 8 years ago

efalk commented 8 years ago

README file claims that any C99 system should work, but I actually have an older server I want to compile this on that only has C99 and C99 does not work. Even the Makefile specifies C11.

rcls commented 8 years ago

Changing the Makefile to "--std=c99" instead of "--std=c11" works for me. Could you send the exact error you get with c99?

efalk commented 8 years ago

OK, I set --std=c99 and did a build. My results:

$ gcc --version gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make gcc -O2 --std=c99 -Wall -Wextra -Werror -D_GNU_SOURCE -g3 -MMD -MP -MF.deps/branch.o.d -c -o branch.o -c branch.c cc1: warnings being treated as errors In file included from branch.c:19: file.h:64: error: declaration does not declare anything make: *\ [branch.o] Error 1

(Oddly, this is a different error than I got before, without the c99 option.)

When I brought down the master branch from git and tried a build, I got this:

$ make gcc -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -g3 -MMD -MP -MF.deps/branch.o.d -c -o branch.o -c branch.c branch.c: In function 'break_cycle': branch.c:106: error: conflicting types for 'i' branch.c:83: error: previous definition of 'i' was here branch.c:106: error: 'for' loop initial declaration used outside C99 mode branch.c: In function 'tag_released': branch.c:123: error: 'for' loop initial declaration used outside C99 mode branch.c:127: error: conflicting types for 'i' branch.c:123: error: previous definition of 'i' was here branch.c:127: error: 'for' loop initial declaration used outside C99 mode branch.c: In function 'branch_graph': branch.c:158: error: 'for' loop initial declaration used outside C99 mode branch.c:160: error: 'for' loop initial declaration used outside C99 mode branch.c:173: error: redefinition of 'i' branch.c:158: error: previous definition of 'i' was here ...

This is basically related to declaring a variable inside a for() loop, which is a new-ish thing in C.

Anyway, my use case is pretty simple, and cvs-fast-export did the trick for me just fine, and I'm running a pretty old OS on my server (Ubuntu 9), and I'm probably the only person seeing these problems, so if you want to just close this issue, I'm fine with it.

-Ed Falk

On 4/16/16 6:44 PM, rcls wrote:

Changing the Makefile to "--std=c99" instead of "--std=c11" works for me. Could you send the exact error you get with c99?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/rcls/crap/issues/14#issuecomment-210936898

rcls commented 8 years ago

Ok, the error from file.h is due to using an anonymous union. Which appears to be a c11 construct allowed by some versions of gcc in c99 but not your version.

Just removing the "union { ... }" around those two struct members in file.h would probably fix it.

Incidently, the default for your gcc is probably not c99, one that old will be defaulting to c89/c90. I don't intend to support c89/c90, I'm not as masochistic as the kernel folks :-)

efalk commented 8 years ago

Meh; don't worry about it.

Me, I'm kind of old-school. I was doing some maintenance on the app I use to sort my email, and realized that about half of the code in it was K&R C.

-ed falk

On 4/19/16 10:46 AM, rcls wrote:

Ok, the error from file.h is due to using an anonymous union. Which appears to be a c11 construct allowed by some versions of gcc in c99 but not your version.

Just removing the "union { ... }" around those two struct members in file.h would probably fix it.

Incidently, the default for your gcc is probably not c99, one that old will be defaulting to c89/c90. I don't intend to support c89/c90, I'm not as masochistic as the kernel folks :-)

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/rcls/crap/issues/14#issuecomment-212038050

rcls commented 8 years ago

I have updated various comments on exactly what compiler flags to use (-std=gnu99 -fms-extensions should work with gcc back to 3.0 or so).