Subject: Re: [codec] Opus codec on Analog Devices SHARC DSPs - patch needed

From: John Ridges <[email-masked]>
Date: Tue, 22 Nov 2011 13:45:25 -0700

Hello all.

I realize it's rather late in the game, but I can't help but notice that 
several function in the CELT fork of the code use variable names that 
are formatted as system specific macros (e.g. _C). From the GNU docs:

http://gcc.gnu.org/onlinedocs/cpp/System_002dspecific-Predefined-Macros.html

        3.7.3 System-specific Predefined Macros

The C preprocessor normally predefines several macros that indicate what 
type of system and machine is in use. They are obviously different on 
each target supported by GCC. This manual, being for all systems and 
machines, cannot tell you what their names are, but you can use cpp -dM 
to see them all. See Invocation 
<http://gcc.gnu.org/onlinedocs/cpp/Invocation.html#Invocation>. All 
system-specific predefined macros expand to the constant 1, so you can 
test them with either `#ifdef' or `#if'.

The C standard requires that all system-specific macros be part of the 
reserved namespace. All names which begin with two underscores, or an 
underscore and a capital letter, are reserved for the compiler and 
library to use as they wish. However, historically system-specific 
macros have had names with no special prefix; for instance, it is common 
to find |unix| defined on Unix systems. For all such macros, GCC 
provides a parallel macro with two underscores added at the beginning 
and the end. If |unix| is defined, |__unix__| will be defined too. There 
will never be more than two underscores; the parallel of |_mips| is 
|__mips__|.

When the -ansi option, or any -std option that requests strict 
conformance, is given to the compiler, all the system-specific 
predefined macros outside the reserved namespace are suppressed. The 
parallel macros, inside the reserved namespace, remain defined.

We are slowly phasing out all predefined macros which are outside the 
reserved namespace. You should never use them in new programs, and we 
encourage you to correct older code to use the parallel macros whenever 
you find it. We don't recommend you use the system-specific macros that 
are in the reserved namespace, either. It is better in the long run to 
check specifically for features you need, using a tool such as autoconf.

I urge that these variables be renamed, as some build systems will fail 
to build the code (most notably the Android NDK).

John Ridges

---

From: Ralph Giles <[email-masked]>
Date: Tue, 29 Nov 2011 14:11:40 -0800

On 22 November 2011 12:45, John Ridges <[email-masked]> wrote:

> several function in the CELT fork of the code use variable names that are
> formatted as system specific macros (e.g. _C).

Thanks for pointing this out. I've attached a patch which addresses the issue.

 -r