C++ List.h Issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C++ List.h Issue

2,227 Views
tapu
Contributor I
Hi,
I am working on porting an old application to CW tools. I faced some issues. To get more ideas on it,
I created a CW stationary C++ project for 5235EVB. In the already existing main.cpp, I included list.h. On compilation of this main.cpp, I got lots of errors. One typical error looked like:
Error  : illegal overloading 'operator new(unsigned long)'
was declared as 'extern "C" void * (unsigned long)'
now declared as 'void * (unsigned long)throw(std::bad_alloc) '
(included from :
memory:150
list:124
main.cpp:8)
new line 118 ME void* operator new(_CSTD::size_t size) throw(_STD::bad_alloc);
 
Can anyone tell me how do I resolve this?
 
regards
Tapu
Labels (1)
0 Kudos
7 Replies

600 Views
CompilerGuru
NXP Employee
NXP Employee
As the C++ overloading resolution only checks on the arguments, the compiler can obviously not differentiate usages of those two operator new's as they only differ in what they throw and in their linkage.
Not sure about the standard, did not check, but I would make sure all your global (and all FSL provided) operator new declarations and definitions match. Try to look at the preprocessor output.
Also what is "list.h"? Do you mean some compatibility, pre ANSI version of the ANSI <list> header?
(If so, try <list>)
Providing a complete compilable source file showing the problem might help.
Daniel
0 Kudos

600 Views
tapu
Contributor I
Hi,
I am using Code Warrior Version 5.7.0 for Coldfire 523*.
 
You are right. Actually what I am using is <list> and not list.h (my mistake in writing the previous messages!).
And regarding cross-checking my declarations/definitions, I am afraid I have not written any code to cross-check. What I did is in the CW IDE I created a new stationary C++ project for 5235EVB. Then in the main.cpp (that it automatically gave), I included <list>. On compilation, I got the above errors.
 
I checked the preprocessor output too. I am not sure from where it is getting 2 definitions/declarations for new because in the preprocessor output file, I could never see the other new declaration.
 
As everyone might be saying, I think may be it is some license issue. My main.cpp is simple and it looks like:
 
/*
 * File:  main.cpp
 * Purpose:  sample program
 *
 */
#include <stdio.h>
#include <list>
int main()
{
 printf("Hello World in C++\n\r");
 
 fflush(stdout);
 
 while(1); // Idle
 
 return 0;
}
 
 
regards
tapu
0 Kudos

600 Views
CompilerGuru
NXP Employee
NXP Employee
With CW for ColdFire 6.3, Build 060609, I can compile your snippet without any problem.
The C++ stationary for the 5235 EVB is actually different from your's, mine was using the C++ cout, not the C style printf as your.
Anyway, it built with your code, so I wonder which version you are using.

Copied from Crazycat:
>To retrieve the actual version number:
> To retrieve that info:
> - Start CodeWarrior
> - Select Help -> About Freescale CodeWarrior
> - Click on "Install Products"
> - CodeWarrior version used is displayed on top in the Installed Products dialog.


Daniel
0 Kudos

600 Views
tapu
Contributor I
Hi,
My version number is version 6.3, Build14.
 
regards
Tapu
0 Kudos

600 Views
J2MEJediMaster
Specialist I
What Codewarrior edition you using (Special, Standard, Pro)? And what is the version number? The problem with C++ might be due to the fact that if you're using the Special Edition, there isn't C++ support. See this thread for more info.

---Tom
0 Kudos

600 Views
tapu
Contributor I
Hi,
I purchased a license for CW professional edition.  After getting the CodeWarrior Development Studio (for Coldfire Architectures Professional Edition) I registered that and then got a license.dat over email. So unless Freescale did some mistake in sending me a correct license file, I think I have a professional license.
 
If I just create a CW stationary C++ project and compile that I see no issues. All the errors that I get appears only after I include a list.h.
 
regards
Anirudha Sarangi
0 Kudos

600 Views
Alban
Senior Contributor II
That is to avoid this kind of messages that in bold and capitals is posted on the of the CodeWarrior page:
 
..........
0 Kudos