keyword inline from C99

Discussion around programming R'n'D, its source code and its tools.

Moderators: Zomis, Flumminator

Post Reply
KH
Posts: 1
Joined: Sun Aug 21, 2005 9:31 pm

keyword inline from C99

Post by KH » Sun Aug 21, 2005 10:52 pm

Hi,

I encountered some problems building RND 3.1.1 on IRIX (with the Mipspro compiler) and
on Solaris (with Sun Studio).
From the error messages and my research on the web, I conclude that the code does not
comply with the restrictions put on the usage of the new "inline" keyword in the C99
standard.

If i do _not_ enable C99 on IRIX, the compiler complains:

/usr/people/heinz/pkgsrc/games/rocksndiamonds/work/.mipspro/bin/cc -O2 -64 -I/usr/people/heinz/pkgsrc/games/rocksndiamonds/work/.buildlink/include -DTARGET_X11 "-DRO_GAME_DIR=\"/usr/people/heinz/pkg/share/rocksndiamonds\"" "-DRW_GAME_DIR=\"/usr/people/heinz/pkg/var/games/rocksndiamonds\"" -c system.c -64 -L/usr/people/heinz/kgsrc/games/rocksndiamonds/work/.buildlink/lib

cc-1077 cc: ERROR File = x11.h, Line = 337
The indicated declaration has no storage class or type specifier.

inline void X11InitVideoDisplay(void);
^
cc-1065 cc: ERROR File = x11.h, Line = 337
A semicolon is expected at this point.

inline void X11InitVideoDisplay(void);
^
[ 100 other messages snipped ]

With C99 enabled, I get this:

cc-3580 c99: ERROR File = system.c, Line = 333
an entity with internal linkage cannot be referenced within an inline function
with external linkage

video.depth = GetRealDepth(depth);
^
[ similar errors in lines 356, 401, 442, 448, 449, 463, 473, 532, 1197 of system.c ]

GetRealDepth() is a static function ("an identifier with internal linkage") and is not allowed
to be referenced from within InitVideoBuffer() ("an inline definition with external linkage").
See chapter 6.7.4 of the C99 standard I found here:
http://www.open-std.org/jtc1/sc22/wg14/ ... /n1124.pdf



The errors

cc-3292 c99: ERROR File = x11.h, Line = 337
The extern inline function "X11InitVideoDisplay" was referenced but not
defined.

inline void X11InitVideoDisplay(void);
^
[ similar errors in line 338, 343 - 349 in x11.h]

seem to happen because there is no definition of X11InitVideoDisplay() available in the
translation unit for system.c, only the included declaration in x11.h.

I think
http://www.comeaucomputing.com/techtalk/c99/#inline
shows this rule with the function "NotDefined()".

Similar problems appear in gadget.c and probably other files I have not reached yet.

If you care about compilers other than gcc (which obviously handles "inline" in its own,
non-compliant way), I think the use of "inline" and "static" should be reconsidered.

ciao
Klaus

PS: Is there no decent mailing list? Writing in web forums sucks, IMNSHO.

Flumminator
Posts: 158
Joined: Fri Jun 18, 2004 8:08 pm
Location: Germany

Post by Flumminator » Mon Aug 22, 2005 9:39 am

I compiled RnD once with the Sun-Compiler and radically removed all "inline"s for it to work...
Flumminator->PostCounter += 1;

User avatar
Holger
Site Admin
Posts: 3231
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger » Mon Aug 22, 2005 3:31 pm

Hello Klaus, welcome to the R'n'D forum! :-)

> If you care about compilers other than gcc

In fact, I do! (Although I must admit that I currently only test the code against incarnations of gcc, as they are the following: gcc on Linux, cross-win32 gcc on Linux, cross-msdos gcc on Linux, gcc on Max OS X and gcc on Solaris -- the fact that I don't test against other compilers is not ignorance, but a question of availability (or the lack of availaibility) of other compilers. For example, even on a Solaris box I tested R'n'D on, gcc was the "default compiler" when invoking "cc". I will see if I can redefine the environment to use the Sun compiler, to get a better estimate if the code works with other compilers.)

> (which obviously handles "inline" in its own,
> non-compliant way), I think the use of "inline" and "static" should be
> reconsidered.

You are right. I used the "inline" keyword for externally referenced functions merely as a hint for myself that these functions should better be made "real" inline functions (currently they will never be inlined by no compiler on earth anyway). I did not know that this breaks the C99 standard, probably mainly because I get no warning at all from gcc. :-(

I should fix this.

> PS: Is there no decent mailing list? Writing in web forums sucks, IMNSHO.

I agree, I also prefer mailing lists! ;-D

In fact, I already had three mailing lists ready to go (for announcements, user discussions and developers), but then I was convinced that the target audience would strongly prefer a web forum over a mailing list. I wasn't that sure, but then I agreed to the web forum because I got help setting it up and all, saving valuable time. :-) Unfortunately, the first two attempts had problems, so it ended with this third (and final) forum on my own server.

Maybe I should give the mailing lists another try? But there's the danger that it "splits forces" (for example users not knowing where exactly to look for help for their problem) -- especially when considering the fact that the number of people interested in this kind of (retro) game is relatively small anyway... :-/

Guest

Post by Guest » Mon Aug 22, 2005 8:30 pm

Flummi wrote: I compiled RnD once with the Sun-Compiler and radically removed all "inline"s for it to work
Well, so we can do it all over again :-)
Holger wrote: In fact, I do! (Although I must admit that I currently only test the code against incarnations of gcc, as they are the following: gcc on Linux, cross-win32 gcc on Linux, cross-msdos gcc on Linux, gcc on Max OS X and gcc on Solaris -- the fact that I don't test against other compilers is not ignorance, but a question of availability (or the lack of availaibility) of other compilers.
If the sentence sounded a bit disparaging I am sorry, this was not intended. Gcc is
universally available and doesn't cost money.
Holger wrote: You are right. I used the "inline" keyword for externally referenced functions merely as a hint for myself that these functions should better be made "real" inline functions (currently they will never be inlined by no compiler on earth anyway). I did not know that this breaks the C99 standard, probably mainly because I get no warning at all from gcc. :-(

I should fix this.
Time permitting, I can help. I have Solaris with a version of Sun Studio 7 (a bit old now).
and I can also access a machine running IRIX 6.5 with Mipspro 7.4.
Holger wrote:
In fact, I already had three mailing lists ready to go (for announcements, user discussions and developers), but then I was convinced that the target audience would strongly prefer a web forum over a mailing list. I wasn't that sure, but then I agreed to the web forum because I got help setting it up and all, saving valuable time. :-) Unfortunately, the first two attempts had problems, so it ended with this third (and final) forum on my own server.
I would not have expected this "strong preference" but it's a valid point, as well as the
help from other people in setting this forum up.
Isn't it possible to attach a mailing list to one of those forums? Connecting the "programmer's corner" with a development list would probably be sufficient.
But if it's too much work, I think I can adapt to the situation.

ciao
Klaus

Post Reply