|
-
Sep 4th, 2001, 12:40 AM
#1
pre processing directvies ???
What is the meaning of #ifndef ??? is it like #define or if condition ?
-
Sep 4th, 2001, 01:10 AM
#2
transcendental analytic
if not defined.
when you define something with
#define something
the compiler won't process what is between
#ifndef something
and the next
#endif something
where something obviously could be replaced with anything. if you remove the #define line, the lines will be processed.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Sep 4th, 2001, 01:20 AM
#3
Kedaman
Thank you very much ! But here I have some code like this
#ifndef XYZ
#define XYZ
one structure declaration
#endif
Here what will happen ?
-
Sep 4th, 2001, 03:21 AM
#4
This is to make sure that the structure will be declared only once:
First time the compiler sees this:
#ifndef _STR_DEF
_STR_DEF is not defined, so the compiler (actually the precompiler) will execute the code:
#define _STR_DEF
struct str
.
.
.
#endif
Due to nested including, the same header is included a second time, but this time, _STR_DEF is already defined, so the compiler will skip the struct definition, thus preventing an error.
This method is commonly used to prevent headers from being included twice:
#ifndef _MY_HEADER_INCLUDED_
#define _MY_HEADER_INCLUDED_
.
.
.
#endif // _MY_HEADER_INCLUDED_
in VC++, you could also use:
#pragma once
but that is not portable.
All the buzzt
CornedBee
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|