Working in VS 2003.
in a header file:
[test.h]
#ifdef _UNUSED_NAME_3223458 //this is not defined anywhere at anytime
#define TEST123 6789
#endif
[\test.h]
in the implementation file:
[test.cpp]
\\the value of TEST123 will be 6789 or whatever value is assigned to it
even though _UNUSED_NAME_3223458 was never defined and is not present
in any other files.
[\test.cpp]
Also, if you do:
#ifndef _UNUSED_NAME_3223458
#define TEST123 0
#endif
Insert this prior to the other one(so you test for not defined before
defined), TEST123 will have a value of 0 and not 6789.
No errors or warnings.
It is almost as if the variable you testing( _UNUSED_NAME_3223458 which
is never defined at any time) is in an unknown state at the time you
test it.
What is going on here? 17 1712 sh***********@gmail.com wrote: Working in VS 2003.
Perhaps you should ask in 'microsoft.public.vc.language'...
in a header file:
[test.h]
#ifdef _UNUSED_NAME_3223458 //this is not defined anywhere at anytime #define TEST123 6789 #endif
[\test.h]
in the implementation file:
[test.cpp]
\\the value of TEST123 will be 6789 or whatever value is assigned to it even though _UNUSED_NAME_3223458 was never defined and is not present in any other files.
By _definition_ if 'TEST123' has the value 6789 (or whatever), it means
that either 'TEST123' is defined _elsewhere_ *as well* as here, or that
"_UNUSED_NAME_3223458" macro is in fact _defined_ and that's how the C++
preprocessor knows to define 'TEST123".
What you're trying to doubt here is the very basic functionality of the
preprocessor. I am _sure_ it's you who's made the mistake. Are you sure
it's "ifdef" and not "ifndef"?... [\test.cpp]
Also, if you do: #ifndef _UNUSED_NAME_3223458 #define TEST123 0 #endif
Insert this prior to the other one(so you test for not defined before defined), TEST123 will have a value of 0 and not 6789.
No errors or warnings.
It is almost as if the variable you testing( _UNUSED_NAME_3223458 which is never defined at any time) is in an unknown state at the time you test it.
What is going on here?
Impossible to say. Your code fragments do not carry enough information.
You're asking for a rather big leap from those fragments to the notion
that everything else is OK, and you didn't screw up somehow. I'd rather
believe the compiler.
V
--
Please remove capital As from my address when replying by mail sh***********@gmail.com wrote: Working in VS 2003.
in a header file:
[test.h]
#ifdef _UNUSED_NAME_3223458 //this is not defined anywhere at anytime
_UNUSED_NAME_3223458 is reserved to the implementation. You can't use
it in your code.
#define TEST123 6789 #endif
On Wed, 08 Feb 2006 09:00:48 -0800, shane.tietjen wrote: Working in VS 2003.
in a header file:
[test.h]
#ifdef _UNUSED_NAME_3223458 //this is not defined anywhere at anytime #define TEST123 6789 #endif
[\test.h]
in the implementation file:
[test.cpp]
\\the value of TEST123 will be 6789 or whatever value is assigned to it even though _UNUSED_NAME_3223458 was never defined and is not present in any other files.
Put
#undef _UNUSED_NAME_3223458
right before the #ifdef in test.h. If that fixes it, then
_UNUSED_NAME_3223458 is defined *somewhere*. (Preprocessor defines in the
project settings perhaps?)
Also, what if you change it to
#ifdef _UNUSED_NAME_3223458foo
? Does it still behave the same?
- Jay
<sh***********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com... Working in VS 2003.
in a header file:
[test.h]
#ifdef _UNUSED_NAME_3223458 //this is not defined anywhere at anytime #define TEST123 6789 #endif
[\test.h]
in the implementation file:
[test.cpp]
\\the value of TEST123 will be 6789 or whatever value is assigned to it even though _UNUSED_NAME_3223458 was never defined and is not present in any other files.
[\test.cpp]
Also, if you do: #ifndef _UNUSED_NAME_3223458 #define TEST123 0 #endif
Insert this prior to the other one(so you test for not defined before defined), TEST123 will have a value of 0 and not 6789.
No errors or warnings.
It is almost as if the variable you testing( _UNUSED_NAME_3223458 which is never defined at any time) is in an unknown state at the time you test it.
What is going on here?
You don't show how you're checking the value of TEST123. How do you know
its value if it hasn't been defined? Testing for a specific value may not
be a valid test if it is never defined in the first place. (I'm not sure if
that's mandated by the standard, or an implementation detail, though.)
-Howard
I thought I was very clear. TEST123 and _UNUSED_NAME_3223458 are not
defined anywhere in my code nor are they present in any file on the
system. This means that there is no possible way they could be
defined. Not defined.
I understand the compiler is smarter than I am. Thats why I use it
instead of writing Assembly.
Could you explain what you mean by "reserved" and by "You can't use it
in your code."?
Thanks
I have tried the #undef solution before and it produced the same
results. But it IS NOT defined anywhere on the local machine in any
file. I know this becaue I just made up the name with a bunch of
random numbers and then searched for it.
And yes, it will behave the same no matter what name you choose. sh***********@gmail.com wrote: Could you explain what you mean by "reserved" and by "You can't use it in your code."?
The standard says that identifiers that start with an underscore
followed by a capital alpha character are reserved for the implementation.
As are identifiers prefixed with double underscore.
This means you have undefined behaviour, regardless of how likely that
identifier is likely to appear in the implementation.
Ben Pope
--
I'm not just a number. To many, I'm known as a string...
<Quote>
You don't show how you're checking the value of TEST123. How do you
know
its value if it hasn't been defined? Testing for a specific value may
not
be a valid test if it is never defined in the first place. (I'm not
sure if
that's mandated by the standard, or an implementation detail, though.)
-Howard
<\Quote>
I check it using the debugger at runtime. I searched every file on the
local machine and "TEST123" and "_UNUSED_NAME_xxxx" not listed as being
part of any other file other than the lines I showed you in the .h file
and .cpp file we are dealing with.
<quote> Could you explain what you mean by "reserved" and by "You can't use it in your code."?
The standard says that identifiers that start with an underscore
followed by a capital alpha character are reserved for the
implementation.
As are identifiers prefixed with double underscore.
This means you have undefined behaviour, regardless of how likely that
identifier is likely to appear in the implementation.
<quote>
Okay I accept that. I wasn't trying to confuse anyone with the name.
Truth is, the name doesn't matter so assume my original problem without
the "_" at the beginning. Sorry for any confusion.
Ben Pope wrote: sh***********@gmail.com wrote:
Could you explain what you mean by "reserved" and by "You can't use it in your code."?
The standard says that identifiers that start with an underscore followed by a capital alpha character are reserved for the implementation.
As are identifiers prefixed with double underscore.
Actually, as are identifiers _containing_ double underscores (17.4.3.1.2).
This means you have undefined behaviour, regardless of how likely that identifier is likely to appear in the implementation.
V
--
Please remove capital As from my address when replying by mail
<sh***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... <Quote> You don't show how you're checking the value of TEST123. How do you know its value if it hasn't been defined? Testing for a specific value may not be a valid test if it is never defined in the first place. (I'm not sure if that's mandated by the standard, or an implementation detail, though.)
-Howard <\Quote>
I check it using the debugger at runtime. I searched every file on the local machine and "TEST123" and "_UNUSED_NAME_xxxx" not listed as being part of any other file other than the lines I showed you in the .h file and .cpp file we are dealing with.
I'd question the debugger, then. Try actually using code or more
preprocessor directives to test if it's defined, and what its value is. I
bet it's simply not defined, which is confusing the debugger. Try something
like this to test:
// in header file:
#ifdef _UNUSED_NAME_3223458 //this is not defined anywhere at anytime
#define TEST123 6789
#endif
// in a function somewhere in a file which includes that header:
#ifdef TEST123
int testInt = TEST123;
#else
int testInt = 0;
#endif
// Now, check or display the value of testInt!
-Howard sh***********@gmail.com wrote: I thought I was very clear. TEST123 and _UNUSED_NAME_3223458 are not defined anywhere in my code nor are they present in any file on the system. This means that there is no possible way they could be defined. Not defined.
I understand the compiler is smarter than I am. Thats why I use it instead of writing Assembly.
No, the compiler is not smarter. It's just more careful at following
the rules imposed on it.
Read the FAQ 5.8, and follow its recommendations. Then we can talk. So
far you're just too frustrated about your problem to hear what others are
telling you.
V
--
Please remove capital As from my address when replying by mail sh***********@gmail.com wrote: <quote>
Could you explain what you mean by "reserved" and by "You can't use it in your code."?
The standard says that identifiers that start with an underscore followed by a capital alpha character are reserved for the implementation.
As are identifiers prefixed with double underscore.
This means you have undefined behaviour, regardless of how likely that identifier is likely to appear in the implementation. <quote>
Okay I accept that. I wasn't trying to confuse anyone with the name. Truth is, the name doesn't matter so assume my original problem without the "_" at the beginning. Sorry for any confusion.
No. We won't assume anything. Assumption is the mother of all f***-ups.
Post complete minimal code that demonstrates your problem.
V
--
Please remove capital As from my address when replying by mail
<quote> I thought I was very clear. TEST123 and _UNUSED_NAME_3223458 are not defined anywhere in my code nor are they present in any file on the system. This means that there is no possible way they could be defined. Not defined.
I understand the compiler is smarter than I am. Thats why I use it instead of writing Assembly.
No, the compiler is not smarter. It's just more careful at following
the rules imposed on it.
Read the FAQ 5.8, and follow its recommendations. Then we can talk.
So
far you're just too frustrated about your problem to hear what others
are
telling you.
V
<\quote>
No I am not frustrated. I actually solved the problem a while ago by
modifying other code so I was not required to use the initial #ifdef in
the header file. No frustrations here at all. I just don't know why
the code was behaving the way it was. And it IS "Smarter" than me. LOL.
The way I meant assume: Similar to writing a mathematical proof,
"Assume the problem is the same as it was originally and get rid of the
"_" in the name". Since the name of the variable doesn't matter( as
long as it is a valid name ), it doesn't change the original nature of
the problem which is what I wanted you to "asume".
sorry for any confustion.
"Howard" <al*****@hotmail.com> wrote in message
news:TD*********************@bgtnsc05-news.ops.worldnet.att.net... <sh***********@gmail.com> wrote in message news:11**********************@z14g2000cwz.googlegr oups.com... <Quote> You don't show how you're checking the value of TEST123. How do you know its value if it hasn't been defined? Testing for a specific value may not be a valid test if it is never defined in the first place. (I'm not sure if that's mandated by the standard, or an implementation detail, though.)
-Howard <\Quote>
I check it using the debugger at runtime. I searched every file on the local machine and "TEST123" and "_UNUSED_NAME_xxxx" not listed as being part of any other file other than the lines I showed you in the .h file and .cpp file we are dealing with.
I'd question the debugger, then. Try actually using code or more preprocessor directives to test if it's defined, and what its value is. I bet it's simply not defined, which is confusing the debugger. Try something like this to test:
// in header file: #ifdef _UNUSED_NAME_3223458 //this is not defined anywhere at anytime #define TEST123 6789 #endif
// in a function somewhere in a file which includes that header: #ifdef TEST123 int testInt = TEST123; #else int testInt = 0; #endif // Now, check or display the value of testInt!
-Howard
Heck, I think I would just do:
#ifdef UNUSED_NAME_3223458
#slakjfsl;adkjfsal;kdjf
#endif
and see if the compiler barfs or not. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ágoston Bejó |
last post by:
Hi there,
In the old Pascal-times, you could set compiler switches in the source code,
with a syntax like {$G+}, things like that (I don't remember them accurately
anymore).
Is there something...
|
by: Skybuck Flying |
last post by:
Hi,
I think I understand now a bit better what the difference is between a c
compiler and a pascal compiler.
For example:
When compiling source code with a pascal compiler. The pascal...
|
by: ramyach |
last post by:
Hi friends,
I need to write a parallel code in 'C' on the server that is
running SGI Irix 6.5. This server supports MIPS Pro C compiler. I don't
have any idea of parallel C languages. I looked...
|
by: cody |
last post by:
the following leads to an error (note that TEST is not defined):
#if TEST
string s = @"
#"; // <-- the error is "preprocessing directive expected"
#endif
also, here we get the same error:
...
|
by: smnoff |
last post by:
Ok, I am think I am a little more knowledgeable about C and pointers, ughh.
And likewise, I want to fix C.....and not so much to make a C++ or Java or
C# or even D like language.
So, if I...
|
by: Ark |
last post by:
A function
int foo(struct T *x)
{
return (x+1)-x;
}
should always return a 1, no matter how T is defined. (And int could be
replaced with ptrdiff_t for you pedants.)
For one thing, it was...
|
by: p_cricket_guy |
last post by:
Please see this test program:
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <limits.h>
4
5 int main (void)
6 {
7 int y = -2147483648;
8 int x = INT_MIN;
|
by: andreas.luethi |
last post by:
Hi All
Compile a our source with BM XL C/C++ Enterprise Edition V8.0 for AIX
(Version: 08.00.0000.0000) produces a lot of Informational message
like this:
"aaalib.c", line 671.1: 1506-412 (I)...
|
by: norseman |
last post by:
Hendrik van Rooyen wrote:
=============================================
.....dreaded.... Yep! I know the feeling. Got lots of those T-Shirts. ;)
I re-read your original post. I got the...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
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 :...
|
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...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
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...
|
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...
|
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...
| |