Bug#467225: libsdl1.2debian: single-line comment produces warnings in C

dwk dwks at theprogrammingsite.com
Sat Feb 23 22:33:29 UTC 2008


Package: libsdl1.2debian
Version: 1.2.13-2
Severity: minor
Tags: patch

After a recent update of the SDL, from version 1.2.11 to 1.2.12 (as
given by `sdl-config --version'), programs compiled in C with GCC's
-ansi and -pedantic flags produce many, many instances of this warning:

/usr/include/SDL/begin_code.h:94:8: warning: extra tokens at end of
#endif directive

Here are lines 86-94 of begin_code.h:

#ifdef __SYMBIAN32__
#ifndef EKA2
#undef DECLSPEC
#define DECLSPEC
#elif !defined(__WINS__)
#undef DECLSPEC
#define DECLSPEC __declspec(dllexport)
#endif //EKA2
#endif //__SYMBIAN32__

The warning occurs because of the single-line // comments after the
#endifs. When compiling in pedantic mode with the -ansi flag for GCC,
single-line comments are not recognized, in compliance with the ANSI
C89 standard. The comment after the endif -- only the __SYMBIAN32__
#endif is parsed on my platform, but the same problem would happen
with the other one -- is seen as just plain text instead of as a
comment. C89 does not allow text after endifs, and hence the warning.
(-pedantic without -ansi warns about these comments, but recognizes
them for what they are: C++-style single-line comments.)

This simple bug manifests itself many, many times, because begin_code.h
is included by every other SDL header file.

$ cat include.c
#include "SDL.h"

int main() {
    return 0;
}

$ gcc -I /usr/include/SDL -ansi -c include.c 2>&1 | wc
     87     364    4882
$

These many messages can easily hide other, more important messages.
Thus, I have recently been using -Wno-endif-labels (after all other
warning flags, in case those flags should enable this warning). It
disables warnings about text appearing after endif labels. It's a
temporary fix, but better than dozens of warnings.

Finally, there is of course a very simple fix for this bug: use
multi-line comments. By changing

#endif //EKA2
#endif //__SYMBIAN32__

to

#endif /* EKA2 */
#endif /* __SYMBIAN32__ */

all of the abovementioned issues are resolved.

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.22-2-amd64 (SMP w/1 CPU core)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libsdl1.2debian depends on:
ii  libsdl1.2debian-alsa          1.2.13-2   Simple DirectMedia Layer (with X11

libsdl1.2debian recommends no packages.

-- no debconf information





More information about the Pkg-sdl-maintainers mailing list