1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 <2011> 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 <2011> 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: how to build c++ |
From: | Dirk Zimoch <[email protected]> |
To: | yangyong203 <[email protected]> |
Cc: | EPICS tech-talk <[email protected]> |
Date: | Wed, 30 Mar 2011 09:36:56 +0200 |
Andrew Johnson wrote:
On Tuesday 29 March 2011 07:11:57 yangyong203 wrote:My error messages as follow: ------------------------------------------------------------------- /usr/bin/g++ -c -D_POSIX_C_SOURCE=199506L -D_POSIX_THREADS-D_XOPEN_SOURCE=500 -D_X86_ -DUNIX -D_BSD_SOURCE -Dlinux -D_REENTRANT -O3 -Wall -m32 -g -fPIC -I. -I../O.Common -I.-I.. -I../../../include/os/Linux -I../../../include-I/epics0320/base/include/os/Linux -I/epics0320/base/include ../dbSubExample.cppIn file included from ../dbSubExample.cpp:6: /epics0320/base/include/aSubRecord.h:163: error: expected unqualified-id before ‘!’ token ---------------------------------------------------------Ah, this is a very specific problem with the aSub record, which contains a field named 'NOT', which becomes a structure data member 'not'. The word 'not' is a reserved word in C++ (which the compiler has replaced with the synonym '!' in the above error message) but not in C, thus the dbSubExample.c file compiles but it doesn't if you rename it and try to use the C++ compiler.There is a very simple fix though: Insert the following macro definition into your dbSubExample.cpp file before the #include <aSubRecord.h> line:#define not no_tThis will change the name that the C++ compiler sees for that data member into something that it accepts, and the result should then compile properly.- Andrew
... or add CXXFLAGS+=-fno-operator-names to one of the used CONFIG.* files. Dirk