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=extend ed -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! 4 1886
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.
Dan Stromberg wrote: [..] The error I get with xlC_r is:
xlC_r -qlanglvl=extend ed -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
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=extend ed: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::V ars_iter" is not declared.
....on the line:
Constructor::Va rs_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 "Constructo r::" thing a g++-ism? If so, is there a good
equivalent in portable C++?
Thanks!
"Dan Stromberg" <st******@dcs.n ac.uci.edu> wrote in message
news:pa******** *************** *****@dcs.nac.u ci.edu... 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=extend ed: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::V ars_iter" is not declared.
...on the line:
Constructor::Va rs_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::Va rs_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 "Constructo r::" thing a g++-ism?
Constructor syntax and semantics are part of standard C++.
-Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 little easier. (That's
what I mean by portability in this case.)
I often go between my day job and my home, carrying code. I used to
either email it to myself and pick it up, or FTP it to my website, or
risk everything and put it on a floppy....
|
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 noted that when I write code I must use lots of platform
specific system calls (POSIX and X/OPEN). Often I found myself using
threads and concurrent processes with some sort of IPC. Some time I
need some socket API. When I just want to open a...
|
by: sathya_me |
last post by:
friends,
Please go through the following code which I have downloaded from Bob
Stout (Snippets):
#include <stdio.h>
|
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 source code and
recompile) is a myth started 20-30 years ago when world consisted of
UNIX systems. Well, world does not consist of UNIX systems anymore, but
there are 100s of different systems running in cell-phones, DVD players,
game consoles...
|
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 can't see
how the authors get paid, so they don't much inspire my ambition for
pursuing perfection, which is inate nonetheless.
In real life, how many of you knowledgable people are ever actually
consigned to write code that will port to very...
| |
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 : %d\n",sizeof(unsigned char));
printf("short : %d\n",sizeof(short));
printf("unsigned short : %d\n",sizeof(unsigned short));
printf("int : %d\n",sizeof(int));
|
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:
#include <stdio.h>
|
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 so that it will compile in all old and broken
compilers, preferably in such a fashion that it can be moved with no
effort from the embedded system in the coffe machine to the 64 bit
processor in your desktop.
|
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 users request are a part of the OpenSource
community. Many if not most of those applications strongly require the
presence of the GNU compiling suite to work properly. My assumption is that
this is due to the author/s creating the applications...
|
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 must be at least 16-Bit.
Now the problem here is that these two criteria conflict if the
natural type for the system is in fact 8-Bit, which is the case with
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |