[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Compiling a project with '-ansi'
- From: Niccolo Medici <niccolomedici@...>
- Date: Thu, 1 Sep 2016 12:23:33 +0300
On 9/1/16, Sam Putman <firstname.lastname@example.org> wrote:
> On Wed, Aug 31, 2016 at 9:29 AM, Niccolo Medici <email@example.com>
>> In a project I'm writing I want to ensure my C code doesn't use
>> newfangled features, so I compile it with `-ansi` (or `-std=c90`). I'm
>> using gcc.
>> However, in this mode the compiler emits an error:
>> error: #error "Compiler does not support 'long long'. Use option
>> or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)"
>> What should I do?
> One possibility is to use, instead of -ansi, the flag -Wc90-c99-compat
> This will issue warnings rather than errors for newfangledness.
Thanks for the advise!
I ended up using "-Wc90-c99-compat -Wno-long-long".
Here are my findings:
0. The problem pertains to Lua 5.3 only. (Earlier ones don't support
integers, so the "long long" issue doesn't exist there, IIUC.)
1. We can't use -ansi (or -std=c90) because this eventually triggers
the #error line in 'luaconf.h'. At least in the stock Lua package that
comes with Ubuntu.
2. So instead we have to use warnings: -Wc90-c99-compat.
2.a. Unfortunately, while the -Wc90-c99-compat switch exists in gcc, I
don't know of equivalent clang switch.
3. We also need to add -Wno-long-long so that the Lua headers work.