472,983 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 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 1839
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.