473,394 Members | 2,063 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,394 software developers and data experts.

Easy way to Compile old g++ 2,95.3 code with newer g++ 3.4

I have some piece of code compiled earlier with g++ 2.95.3. When I try to compile the code in new g++ version 3.4.3, the compilation fails with error
"error: invalid in-class initialization of static data member of non-integral type `const char* const'".
I recognize the problem. I have header files with variables initialized inside the class definition. When I move the variable initialization to class constructor, it compiles without any issue. But I have too many such files, and I do not wish to make similar changes to all such files (moving variable initialization outside .H file). Is there a easy way to compile my code with newer versions of g++/gcc
Sep 2 '11 #1
1 1933
weaknessforcats
9,208 Expert Mod 8TB
A static variable is not a member of the class. That is, you don't need a this pointer to access the variable. Because it's not part of the class you can't initialize it inside the class declaration. However, it has the scope of the class so you will need the scope reslution operator to work with the variable.

You will need to create these variables as global variables.

BTW: A static variable is form of global variable and global variables should not be used in C++. Read: http://bytes.com/topic/c/insights/73...obal-variables.

I suggest using Singleton objects instead.
Sep 6 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: normd | last post by:
I have a text file which contains VB.NET code. The VB.NET code is actually a Class that can contain code, which simply displays a message box or does something more complicated (i.e Excel/Word...
3
by: Matt | last post by:
I'm trying to simply convert a .avi file recorded by our program to a wmv file, of course compressed as possible. I've looked at the examples provided by microsoft @...
1
by: Adam Clauss | last post by:
OK, I just ran across a program that did this and I am wondering is this something they coded in themselves, or is there already helper classes, etc available to assist in this. The application...
0
by: Cybertof | last post by:
It is possible to compile on the fly some c# code and then execute it (with System.Codedom.Compiler) How to give this 'piece of code' the possibility to view/access some specific namespace...
1
by: Mian Mahboob | last post by:
Hi in my application i need to save C sharp syntax to SQL Server database then need to call that on Windows UserControl then execute that code and get there output. all i done accept to execute...
2
by: sarojanand | last post by:
Hi, I have created a project (abc) in my wwwroot folder on my system. From visual studio, i am able to run and view this page. Now I have deployed on wwwroot folder and for this I have edited...
1
by: Aras Kucinskas | last post by:
Hello, I have developed a web application using VS 2005. The application contains couple of independent modules. The forms and controls code files are separated in to .vb and .ascx. Now I want...
3
by: Rabel | last post by:
I am having trouble with our server host they are saying that the php upload limit is 20 mbs but using the code below with my flash file I can only get it to do 8mbs. I know that asp is allowing...
5
by: cmdolcet69 | last post by:
When i compile the code below it error out saying that Object Reference not set to an instance of an object...... Public newRuntimeClass As NewRuntimeMethods Private Sub btnOK_Click(ByVal...
21
by: sevak316 | last post by:
I wasn't sure how what subject to put for this, but what I really want to know is how to compile code which is located outside of my Visual Studio project folder. For example if my project is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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...
0
jinu1996
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...
0
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...
0
tracyyun
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...

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.