[Home]

Summary:ASTERISK-09542: Use of reserved C++ terms
Reporter:Oskar Senft (osk)Labels:
Date Opened:2007-05-29 17:42:12Date Closed:2007-07-11 19:59:09
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:In the current SVN version reserved C++ terms (like new, delete, ...) are used in several files. This causes problems when using a C++ compiler for modules written in C++.

At least these two examples are currently present:

app.h
int ast_app_group_update(struct ast_channel *old, struct ast_channel *new);

speech.h
struct ast_speech_engine {
[...]
 int (*new)(struct ast_speech *speech);
[...]
}
Comments:By: Tilghman Lesher (tilghman) 2007-05-30 00:06:45

More details on this are needed.  What compiler/platform are you trying to use?

By: Oskar Senft (osk) 2007-05-30 02:43:48

# g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

By: Oskar Senft (osk) 2007-05-30 02:52:10

Sample compiler error:

/usr/include/asterisk/app.h:231: error: expected ',' or '...' before 'new'


When compiling the following snippet:

---snipp---
#ifdef __cplusplus
extern "C" {
#endif

#include <asterisk/pbx.h>
#include <asterisk/app.h>

#ifdef __cplusplus
} // extern "C" {
#endif
---snapp---

# g++ -D_GNU_SOURCE -c source.c

By: Tilghman Lesher (tilghman) 2007-05-30 08:10:26

I'm afraid that this is then a feature request, not a MAJOR bug, as you could quite easily avoid this problem by using the gcc compiler.

By: Russell Bryant (russell) 2007-05-30 10:47:50

Corydon76:  Yes, but that does not solve the problem of using these APIs from modules written in C++, which is what the original report is about.

By: Oskar Senft (osk) 2007-05-30 12:53:46

Renaming the variable names should not be a big problem as it does not change the semantics at all. But I think it's most important to avoid adding more problems like this - as up to 1.4.x the code compiled with C++. What does Kevin say about this? I think he was a bit "pro C++"?

By: Russell Bryant (russell) 2007-05-30 16:08:43

No, I would not classify kevin as very "pro C++".  :)

Anyway, yeah, the variables just need to be renamed.  I don't think that is a big deal.

By: Tilghman Lesher (tilghman) 2007-05-30 19:48:35

In the case of the speech API, it is a big deal.  The Lumenvox package would probably need to be rebuilt, since the method name would change.

By: Joshua C. Colp (jcolp) 2007-05-31 10:24:15

I would be fine with doing so, I already publish a minimum required version/tested version in the Lumenvox packages so I would just add a note. The group one can also easily be changed.

By: Russell Bryant (russell) 2007-05-31 13:44:01

The two instances you pointed out have been fixed in 1.4 and trunk in revisions 66775 and 66776.  If you find any more, please report another bug.  Thanks!