Discussion:
[omniORB] CORBA.h and std::min collision in VC++ 7.1
Stefan Wegele
2007-03-13 14:02:35 UTC
Permalink
Hello,

I have a problem using std::min and a corba object in the same file.
Here is the example:

#include <iostream>
#include <omniORB4/CORBA.h>
int main(int argc, _TCHAR* argv[])
{
long a=23, b=345;
long c = std::min(a, b);
std::cout << c << std::endl;
return 0;
}

I get:
error C2589: '(' : illegal token on right side of '::'
error C2059: syntax error : '::'
for the line with std::min.
If I remove the include of Corba.h then it works perfectly.

I declared: __WIN32__,__x86__,_WIN32_WINNT=0x0400, __NT__ and
__OSVERSION__=4
VC++ version: 7.1.6

Thanks, Stefan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20070313/779406f2/attachment.htm
Dominguez, Jose Luis
2007-03-13 16:23:30 UTC
Permalink
try using namespace std instead of std::

________________________________

From: omniorb-list-***@omniorb-support.com
[mailto:omniorb-list-***@omniorb-support.com] On Behalf Of Stefan
Wegele
Sent: martes, 13 de marzo de 2007 10:03
To: omniorb-***@omniorb-support.com
Subject: [omniORB] CORBA.h and std::min collision in VC++ 7.1


Hello,

I have a problem using std::min and a corba object in the same file.
Here is the example:

#include <iostream>
#include <omniORB4/CORBA.h>
int main(int argc, _TCHAR* argv[])
{
long a=23, b=345;
long c = std::min(a, b);
std::cout << c << std::endl;
return 0;
}

I get:
error C2589: '(' : illegal token on right side of '::'
error C2059: syntax error : '::'
for the line with std::min.
If I remove the include of Corba.h then it works perfectly.

I declared: __WIN32__,__x86__,_WIN32_WINNT=0x0400, __NT__ and
__OSVERSION__=4
VC++ version: 7.1.6

Thanks, Stefan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20070313/6ec8a596/attachment.htm
Stefan Naewe
2007-03-13 16:33:01 UTC
Permalink
Post by Stefan Wegele
I have a problem using std::min and a corba object in the same file.
#include <iostream>
#include <omniORB4/CORBA.h>
int main( int argc, _TCHAR* argv[])
{
long a=23, b=345;
long c = std::min(a, b);
std::cout << c << std::endl;
return 0;
}
error C2589: '(' : illegal token on right side of '::'
error C2059: syntax error : '::'
for the line with std::min.
If I remove the include of Corba.h then it works perfectly.
I declared: __WIN32__,__x86__,_WIN32_WINNT=0x0400, __NT__ and
__OSVERSION__=4
VC++ version: 7.1.6
What difference should that make?

I'd try including the correct header:

#include <algorithm>


Stefan
--
----------------------------------------------------------------------
Dipl.-Inform. Stefan Naewe ATLAS Elektronik GmbH
Dept.: NUS T4
phone: +49-(0)421-457-1378 Sebaldsbruecker Heerstr. 235
fax: +49-(0)421-457-3913 28305 Bremen
Vladislav Vrtunski
2007-03-13 17:00:03 UTC
Permalink
Post by Stefan Wegele
Hello,
I have a problem using std::min and a corba object in the same file.
#include <iostream>
#include <omniORB4/CORBA.h>
int main(int argc, _TCHAR* argv[])
{
long a=23, b=345;
long c = std::min(a, b);
std::cout << c << std::endl;
return 0;
}
error C2589: '(' : illegal token on right side of '::'
error C2059: syntax error : '::'
for the line with std::min.
If I remove the include of Corba.h then it works perfectly.
I declared: __WIN32__,__x86__,_WIN32_WINNT=0x0400, __NT__ and
__OSVERSION__=4
VC++ version: 7.1.6
Thanks, Stefan
Sounds like you have a macro definition of min somewhere in the headers
included by CORBA.h. Try
#undef min
bellow the
#include <omniORB4/CORBA.h>
line.

I think that this is a known problem on Win32. Take a look at this link:
http://www.devx.com/tips/Tip/14540

Regards,

Vladislav
Brian Neal
2007-03-13 18:19:33 UTC
Permalink
Post by Stefan Wegele
I have a problem using std::min and a corba object in the same file.
Unfortunately Microsoft #define's macros min and max (yes, in lower
case). When working with that compiler in the past we have had to do

#undef min
#undef max

before using the those functions. Remember that macros do not respect
scope or namespaces. It really irks me when people don't put
MACRO_NAMES_IN_ALL_UPPER_CASE.

Loading...