473,387 Members | 1,711 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

portability thing?


Hi folks.

I'm working on building some software, some of which is written in C++,
for a researcher here at the University.

I have an extensive background in C and python, but I haven't done much
with C++ - I kind of mostly abandoned C++ some time ago, when I coded a
project in C++, and some of my coworkers refused to use it -because- it
was in C++.

So anyway, I'm working on building a library in C++, and although the
library builds fine with g++, it does not build with IBM's xlC_r (C++,
reentrant). The OS I'm on is AIX 5.1 ML 4.

I was fine with building the library with g++, but the researcher really
wants it built with xlC_r, because he believes (and is probably right)
that xlC_r will produce faster code, and produce a library that can be
linked with either xlC* or g++, while a library compiled with g++ would
appear to be only linkable, on this platform, with g++.
The error I get with xlC_r is:

xlC_r -qlanglvl=extended -q64 /usr/local/lib/libmalloc.a -DHAVE_CONFIG_H -I. -I. -I. -I. -I./gl -I/usr/local/include -I/usr/local/include/libxml2 -I./GNU -g -c -M RValue.cc -DPIC -o .libs/RValue.o
"RValue.cc", line 176.39: 1540-0016 (S) The expression must be an integral constant expression.
gmake[2]: *** [RValue.lo] Error 1
The offending line of RValue.cc is:

BaseType **argv = new (BaseType *[argc + 1]);
Unfortunately, that "*[argc + 1]" wouldn't mean a great deal in C, and I
suspect it's not going to be in many C++ books, because it seems likely
that it's not portable C++, but rather a g++ extension of some sort?
Moreover, it seems a difficult thing to google for due to it being a bunch
of special symbols, rather than keywords...

Anyway, I've tried a few things to get this to build with xlC_r, including
cranking up the permissiveness of what language extensions xlC_r accepts,
but it doesn't seem to be helping.

Does anyone have any suggestions for me?

Thanks!

Nov 22 '05 #1
4 1864
There are chances that I am wrong, but still I give a try -

Dan Stromberg wrote:
Hi folks.
BaseType **argv = new (BaseType *[argc + 1]);


If you want to allocate the memory using the C++ keyword "new", then
the correct syntax is :

BaseType **argv = new BaseType *[argc + 1];

// note that absence of ( )

This will compile on AIX 5.1 with xlC version 6

When you are putting parentheses after new, you are (most likely)
calling operator new(), and not doing a proper construction using new
operator.

Hope this helps.

Nov 22 '05 #2
Dan Stromberg wrote:
[..]
The error I get with xlC_r is:

xlC_r -qlanglvl=extended -q64 /usr/local/lib/libmalloc.a -DHAVE_CONFIG_H -I. -I. -I. -I. -I./gl -I/usr/local/include -I/usr/local/include/libxml2 -I./GNU -g -c -M RValue.cc -DPIC -o .libs/RValue.o
"RValue.cc", line 176.39: 1540-0016 (S) The expression must be an integral constant expression.
gmake[2]: *** [RValue.lo] Error 1
The offending line of RValue.cc is:

BaseType **argv = new (BaseType *[argc + 1]);
[..]


Have you tried dropping the parentheses? As in

BaseType **argv = new BaseType*[argc + 1];

....

Of course, to know whether it's the right thing to do or not, I'd need to
see more code, especially how you use 'argv', but you could start there...

V
Nov 22 '05 #3
On Tue, 15 Nov 2005 11:49:44 -0800, Neelesh Bodas wrote:
There are chances that I am wrong, but still I give a try -

Dan Stromberg wrote:
Hi folks.
BaseType **argv = new (BaseType *[argc + 1]);


If you want to allocate the memory using the C++ keyword "new", then
the correct syntax is :

BaseType **argv = new BaseType *[argc + 1];

// note that absence of ( )

This will compile on AIX 5.1 with xlC version 6

When you are putting parentheses after new, you are (most likely)
calling operator new(), and not doing a proper construction using new
operator.

Hope this helps.


Neelesh and Victor - Removing the parens worked great - thanks much.

I cleared a few more hurdles on my own, but now I've come upon another one
I'd like to get group advice on, hopefully.

Specifically, I'm getting:

xlC_r -I/usr/local/include -qlanglvl=extended:redefmac -D__inline= -DHAVE_CONFIG_H -I. -I. -I. -I./lnetcdf -I./fortran -Df2cFortran -DLOCAL -DDEFAULT_BASETY
PE_FACTORY -I/usr/local/include/libdap -O2 -c -o NCSequence.o `test -f 'NCSequence.cc' || echo './'`NCSequence.cc
"NCSequence.cc", line 310.5: 1540-0130 (S) "Constructor::Vars_iter" is not declared.

....on the line:

Constructor::Vars_iter field = var_begin();

....and I'm not recalling anything about that sort of Constructor keyword
in C++. I'm hazy on this, but I'd sort of thought C++ constructors were at
least somewhat like in python, where you just use the name of the class.

Is this "Constructor::" thing a g++-ism? If so, is there a good
equivalent in portable C++?

Thanks!

Nov 22 '05 #4

"Dan Stromberg" <st******@dcs.nac.uci.edu> wrote in message
news:pa****************************@dcs.nac.uci.ed u...
On Tue, 15 Nov 2005 11:49:44 -0800, Neelesh Bodas wrote:
There are chances that I am wrong, but still I give a try -

Dan Stromberg wrote:
Hi folks.
BaseType **argv = new (BaseType *[argc + 1]);
If you want to allocate the memory using the C++ keyword "new", then
the correct syntax is :

BaseType **argv = new BaseType *[argc + 1];

// note that absence of ( )

This will compile on AIX 5.1 with xlC version 6

When you are putting parentheses after new, you are (most likely)
calling operator new(), and not doing a proper construction using new
operator.

Hope this helps.


Neelesh and Victor - Removing the parens worked great - thanks much.

I cleared a few more hurdles on my own, but now I've come upon another one
I'd like to get group advice on, hopefully.

Specifically, I'm getting:

xlC_r -I/usr/local/include -qlanglvl=extended:redefmac -D__inline= -DHAVE_CONFIG_H
-I. -I. -I. -I./lnetcdf -I./fortran -Df2cFortran -DLOCAL -DDEFAULT_BASETY
PE_FACTORY -I/usr/local/include/libdap -O2 -c -o NCSequence.o `test -f
'NCSequence.cc' || echo './'`NCSequence.cc
"NCSequence.cc", line 310.5: 1540-0130 (S) "Constructor::Vars_iter" is not
declared.

...on the line:

Constructor::Vars_iter field = var_begin();

...and I'm not recalling anything about that sort of Constructor keyword
in C++.


In C++ the word 'constructor' (uppercase or not) is not
a keyword. Your expression:

Constructor::Vars_iter field = var_begin();

... implies that the name 'Constructor' is either a
class name or the name of a namespace, and that the
name 'Vars_iter' is a class member or member of a namespace.
A class member function's "name" is that of its
class. (Technically constructors don't have names, its
just that the syntax makes it look that way).

class C
{
public:
C(){} /* constructor */
};

A constructor is not called directly, it's automatically
called at object creation.

C c; /* creates type 'C' object, calls C::C() */

C(); /* creates a type 'C' object, calls C::C(),
then the object is destroyed (calls C::~C())
(i.e. this creates a 'temporary' object) */

(If you don't define a constructor or destructor, the
compiler will synthesize default ones).
I'm hazy on this, but I'd sort of thought C++ constructors were at
least somewhat like in python, where you just use the name of the class.
I don't know Python, but yes, they have the same 'name'.
But you don't call them directly.

Is this "Constructor::" thing a g++-ism?


Constructor syntax and semantics are part of standard C++.

-Mike
Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Google Mike | last post by:
No, this isn't what you thought the subject of this post meant. It's better. I just wanted to share with you something I did that makes editing PHP and carrying your projects back and forth a...
7
by: fabio de francesco | last post by:
Hi, I'm not a professional programmer, but I've been writing C/C++ and Ada programs for a few years on GNU/Linux without ever concerning on standards and portability to other OSs. I've always...
5
by: sathya_me | last post by:
friends, Please go through the following code which I have downloaded from Bob Stout (Snippets): #include <stdio.h>
93
by: roman ziak | last post by:
I just read couple articles on this group and it keeps amazing me how the portability is used as strong argument for language cleanliness. In my opinion, porting the program (so you just take the...
25
by: Stephen Mayes | last post by:
From lurking on this most excellent newsgroup, I have garnered that an expressed benefit of having a standard is portability of code. I see a lot of open source endeavors that inspire my awe, but I...
35
by: Sunil | last post by:
Hi all, I am using gcc compiler in linux.I compiled a small program int main() { printf("char : %d\n",sizeof(char)); printf("unsigned char : ...
20
by: Jonathan Lamothe | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey all. I'm trying to find a way to (portably) write 32-bit integer values to a file. As it stands, I've been using something like this: ...
93
by: jacob navia | last post by:
In this group there is a bunch of people that call themselves 'regulars' that insist in something called "portability". Portability for them means the least common denominator. Write your code...
239
by: Eigenvector | last post by:
My question is more generic, but it involves what I consider ANSI standard C and portability. I happen to be a system admin for multiple platforms and as such a lot of the applications that my...
33
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
I'll try to summarise this as best I can, as my last thread wasn't very to-the-point: The C Standard says the following two things: * int is the natural integer type for the system. * int...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.