C standard usually used to compile nginx

202 views
Skip to first unread message

Femaref

unread,
Apr 29, 2014, 7:45:12 AM4/29/14
to openre...@googlegroups.com
I'm currently using clang, which defaults to c99 standard. However, gcc uses c90, and if I use -std=c90 on clang, it complains regarding ngx_inline. Example:

In file included from src/core/nginx.c:9:
In file included from src/core/ngx_core.h:41:
src/core/ngx_rbtree.h:73:8: error: unknown type name 'inline'
static ngx_inline ngx_rbtree_node_t *

On gcc (using debian wheezy), it (obviously) complains about inline for declarations:

/home/femaref/nginx/flynx/src/ngx_http_flynx_upstream.c:51:3: error: 'for' loop initial declarations are only allowed in C99 mode

What is usually used for compiling? 

Vladislav Manchev

unread,
Apr 29, 2014, 8:34:34 AM4/29/14
to openre...@googlegroups.com
That's interesting, it works perfectly fine out of the box on FreeBSD 10 with openresty 1.5.12.1rc4 and clang 3.3.
No warnings or errors during compilation.

Is there any chance you're compiling from git repos where something is possibly broken instead of using a release bundle?

Otherwise, I guess there might be a problem with the clang version bundled with Debian.
--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Femaref

unread,
Apr 29, 2014, 8:36:44 AM4/29/14
to openre...@googlegroups.com
I'm sorry, I should have been more specific. The first code is from nginx itself, the second from my the module I'm developing. I'm not using openresty, it was more of a general question (I do have ngx_lua included though).

The clang compile is on OS X, the gcc is on debian.

in...@ecsystems.nl

unread,
Apr 29, 2014, 1:30:06 PM4/29/14
to openre...@googlegroups.com
Here we use vc2010 and vc2013 (windows) which compiles nginx and nearly all openresty modules cleanly, see http://nginx-win.ecsds.eu/ which we use and compiles cleanly. You might be missing compiler includes, or browse thru all the commits agentzh has made to get it to compile for vc++ for hints how some changes have been made for C. Note that we only use full source downloads and not hg,git or whatever diff system.

Vladislav Manchev

unread,
Apr 29, 2014, 1:47:08 PM4/29/14
to openre...@googlegroups.com
Okay, I see now, but still the first error occurring is in nginx core and I don't get any of these with clang 3.3 on FreeBSD 10. Not ever warnings.

As for the second error - you can't use declarations inside the for statement with c90. It was introduced in c99 and so you have two options: either use c99 or declare the variable before the loop.

That's about it, but if you want people on the list to help you I think you should post some code along with the errors.
--

Femaref

unread,
Apr 29, 2014, 3:50:16 PM4/29/14
to openre...@googlegroups.com
Regarding clang:

clang defaults to c99. With no std set, I don't get warnings either, and it compiles cleanly.

I just went through clang documentation, and it looks like clang can use -std=gnu90, which is the same behaviour as gcc defaults to. With that, I don't get the inline problem either, so that should be the solution.
Reply all
Reply to author
Forward
0 new messages