473,382 Members | 1,749 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,382 software developers and data experts.

'static ' : ignored on left of 'const double' when no variable isdeclared

I'm getting this rather cryptic com,pile time error when I compile my
code. I have the following lines in my header file I know I could use
anonymous namespaces to get around this but I was being lazy and simply
wanted to do it the old "C" way).

The header looks like this:

#pragma once

......

#define maximum std::max<double>
static const double ACCURACY=1.0e-6; <- compiler barfs here
static const double ERROR=-1e30;
???
Apr 15 '07 #1
5 7117
Hi,

The problem is most likely with the following line
static const double ERROR=-1e30;

ERROR is defined as a macro which the preprocessor is expanding therefore
making causing this to not be valid a variable declaration.

Hope this helps

--
Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor
"2b|!2b==?" <ro**@your.box.comwrote in message
news:UO*********************@bt.com...
I'm getting this rather cryptic com,pile time error when I compile my
code. I have the following lines in my header file I know I could use
anonymous namespaces to get around this but I was being lazy and simply
wanted to do it the old "C" way).

The header looks like this:

#pragma once

.....

#define maximum std::max<double>
static const double ACCURACY=1.0e-6; <- compiler barfs here
static const double ERROR=-1e30;
???
Apr 15 '07 #2
On Sun, 15 Apr 2007 18:06:55 +0100, "2b|!2b==?" <ro**@your.box.comwrote:
>I'm getting this rather cryptic com,pile time error when I compile my
code. I have the following lines in my header file I know I could use
anonymous namespaces to get around this but I was being lazy and simply
wanted to do it the old "C" way).

The header looks like this:

#pragma once

.....

#define maximum std::max<double>
static const double ACCURACY=1.0e-6; <- compiler barfs here
static const double ERROR=-1e30;
???
When you get an error like this, the first thing to do is copy the
offending line and paste it into a file all by itself. When you find it
compiles OK, and in this case it does for me, look for differences between
the test file and the real compilation environment. As you are using
all-caps for a variable name, and all-caps at least informally is usually
restricted to macros, I'd suspect a conflicting macro definition. You can
compile with /P to review the preprocessor output or simply change the case
a bit to see if that helps.

--
Doug Harrison
Visual C++ MVP
Apr 15 '07 #3
In article <UO*********************@bt.com>,
2b|!2b==? <ro**@your.box.comwrote:
>#define maximum std::max<double>
static const double ACCURACY=1.0e-6; <- compiler barfs here
static const double ERROR=-1e30;
Sometimes, the error is on the line, or the line before.
I'd insert a test line between the #define and the ACCURACY line,
e.g.

#define ...
extern double g_SomeDoubleTestValue;
static const double ...

If it still errors out line after the #define, then the real error
lies above it -- might be a class Foo {} without the closing
semicolon, or something else.

Nathan Mates

--
<*Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein
Apr 15 '07 #4
2b|!2b==? wrote:
I'm getting this rather cryptic com,pile time error when I compile my
code. I have the following lines in my header file I know I could use
anonymous namespaces to get around this but I was being lazy and simply
wanted to do it the old "C" way).

The header looks like this:

#pragma once

.....

#define maximum std::max<double>
static const double ACCURACY=1.0e-6; <- compiler barfs here
static const double ERROR=-1e30;
In addition to the other responses (which indicate the cause of the
error), static here is redundant - const variables at namespace scope
are implicitly "static" anyway, so you can leave off the static keyword.
If you want them to be extern (which you don't of course), you have to
explicitly add extern.

Tom
Apr 16 '07 #5
Error 1: 2b|!2b!=the question. 2b|~2b==the question. Hamlet computed ff
because he operated on bitwisecracks.

Error 2: As Chris Taylor suggested, I think the preprocessor is expanding
the ERROR macro as it's probably supposed to (if you're including just about
any of the common standard headers) and the result is rather cryptic
syntactic garbage in the line after the one you pointed to. At least you're
lucky it didn't result in valid syntax with some meaning completely
different from what you wanted.
"2b|!2b==?" <ro**@your.box.comwrote in message
news:UO*********************@bt.com...
I'm getting this rather cryptic com,pile time error when I compile my
code. I have the following lines in my header file I know I could use
anonymous namespaces to get around this but I was being lazy and simply
wanted to do it the old "C" way).

The header looks like this:

#pragma once

.....

#define maximum std::max<double>
static const double ACCURACY=1.0e-6; <- compiler barfs here
static const double ERROR=-1e30;
???
Apr 17 '07 #6

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

Similar topics

3
by: Marcin Vorbrodt | last post by:
So I have a class Math that looks like this: Math { public: static Real PI(void); }; Real Math::PI(void) { return 4.0 * atan(1.0); }
2
by: Martin Magnusson | last post by:
Hi I have a class with a public const static variable, and I get a number of undefined references to it when linking. The code looks like below. When referencing the variable from other files I...
4
by: cppsks | last post by:
"Defining static const variables inside the class is not universally supported yet, so for now I guess you'll have to move the definition out of the body of the class. No, static const inside...
2
by: Drew McCormack | last post by:
I am getting an error in g++ 4.0.0 that I did not get in g++ 3.4. I have a header with the following const variables with namespace scope: namespace Periphery { extern const double...
3
by: Steve Folly | last post by:
Hi, I had a problem in my code recently which turned out to be the 'the "static initialization order fiasco"' problem (<http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12>) The FAQ...
3
by: StephQ | last post by:
In utility.hpp I have: namespace utility { template <class T, double (T::*F)(double) const> class Display { private: static double resolution;
14
by: Jess | last post by:
Hello, I learned that there are five kinds of static objects, namely 1. global objects 2. object defined in namespace scope 3. object declared static instead classes 4. objects declared...
14
by: cs1975 | last post by:
Hi Everyone, I wanted to make a global variable double rowCols = {{1,0,0},{0,1,0},{1,0,0}}; to static global static double rowCols = {{1,0,0},{0,1,0},{1,0,0}}; I am updating this global...
15
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.