Operating System - HP-UX
1745789 Members
4244 Online
108722 Solutions
New Discussion юеВ

Re: error #2029: expected an expression

 
SOLVED
Go to solution
Alex Vinokur
Frequent Advisor

error #2029: expected an expression

Hi,

HP-UX hpx418 B.11.23 U ia64 1139467043 unlimited-user license

aCC: HP C/aC++ B3910B A.06.25.01 [May 16 2010]


---- hp_uuu.cpp ---
int main()
{
long int x = ({ long int __result; __result = 131; __result; });

return 0;
}

-------------------


====== Compilation ======
> aCC hp_uuu.cpp
"hp_uuu.cpp", line 3: error #2029: expected an expression
long int x = ({ long int __result; __result = 131; __result; });
^

1 error detected in the compilation of "hp_uuu.cpp".

=========================

Cpmpilers SUN CC, AIX xlC, Intel ixpc have np problem with that code.

CC: Sun C++ 5.11 SunOS_sparc 2010/08/13

IBM XL C/C++ for AIX, V10.1
Version: 10.01.0000.0000

Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.0.0.084 Build 20101006
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.


8 REPLIES 8
Steven Schweda
Honored Contributor

Re: error #2029: expected an expression

I don't know enough about C++ even to be
dangerous, but what's the value of a "{}"
code block supposed to be?

Around here:

alp $ cxx hp_uuu.cpp

long int x = ({ long int __result; __result = 131; __result; });
..............^
%CXX-E-EXPPRIMEXPR, expected an expression
at line number 3 in file ALP$DKC0:[SMS.ITRC]hp_uuu.cpp;1

%CXX-I-MESSAGE, 1 error detected in the compilation of "ALP$DKC0:[SMS.ITRC]hp_uuu.cpp;1".

(With a fixed-width font, that "^" points to
the "{".)

alp $ cxx /version
HP C++ V7.3-009 for OpenVMS Alpha V8.3
Alex Vinokur
Frequent Advisor

Re: error #2029: expected an expression


From:
http://www.beastsoft.net/trac/gmediaserver/browser/src/tempfailure.h?order=name


26 /* TEMP_FAILURE_RETRY uses ({ }) syntax which is probably only supported
27 * by GCC. That is why this file is not in Gnulib.
28 */
29
30 #ifndef TEMP_FAILURE_RETRY
31 #define TEMP_FAILURE_RETRY(expression) \
32 ({ \
33 long int _result; \
34 do _result = (long int) (expression); \
35 while (_result == -1L && errno == EINTR); \
36 _result; \
37 })
38 #endif

But why is that compiled on SUN CC, AIX xlC and Intel icpc?

Steven Schweda
Honored Contributor

Re: error #2029: expected an expression

> But why is that compiled on SUN CC, AIX xlC
> and Intel icpc?

Are you asking why all C++ compilers are not
exactly equivalent? I can think at least one
possible reason for this.

> [...] what's the value of a "{}"
> code block supposed to be?

Still wondering.
Dennis Handly
Acclaimed Contributor
Solution

Re: error #2029: expected an expression

This is a GNU statement expression. You'll need to use -Ag++ to enable them.

>Steven: but what's the value of a "{}" code block supposed to be?

__result:
http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
Steven Schweda
Honored Contributor

Re: error #2029: expected an expression

Alex Vinokur
Frequent Advisor

Re: error #2029: expected an expression

Dennis, a lof o thanks.
Dennis Handly
Acclaimed Contributor

Re: error #2029: expected an expression

>ME: You'll need to use -Ag++ to enable them.

In A.06.26, this will be enabled by default.
Alex Vinokur
Frequent Advisor

Re: error #2029: expected an expression

Thanks