[ opengl @ 11.09.2005. 17:10 ] @
Da li moze neko da mi objasni glavne predprocesorske direktive sem include i define
mislim na #ifndef,#pragma,ifdef itd
[ itf @ 11.09.2005. 18:18 ] @
Imaš to sve u help-u.
[ anon28907 @ 11.09.2005. 19:02 ] @
http://www.google.com/search?h...commands+%23ifndef&spell=1

[QUOTE]#IFNDEF - Conditionally includes a set of commands at compile time if a compile-time constant is defined. Specifies that a set of commands is included at compile time when the ConstantName is defined.

The following items describe how a set of commands is included at compile time when you include #IFDEF:

If ConstantName is defined, the set of commands following #IFDEF and preceding #ELSE or #ENDIF (whichever occurs first) is included at compile time.
If ConstantName is not defined and #ELSE is included, the set of commands following #ELSE and preceding #ENDIF is included at compile time.[/QUOTE]

[QUOTE]A preprocessor command is a line of code placed inside a MOF file that controls the way the MOF compiler compiles code. There are two preprocessor commands used in compiling MOF files:

#pragma
#include

The #pragma command is very similar in theory to a command-line switch; however, you do not need to re-enter a #pragma command each time you compile a MOF file. The following example illustrates #pragma command syntax:

#pragma [command]

You usually place a #pragma command at the beginning of a MOF file. However, you can place some commands, such as the #pragma command, in the body of your MOF code. The following example shows #pragma preprocessor commands that indicate to the MOF compiler that it must place classes and instances in the root\cimv2 namespace and compile the file in which the commands are included during repository recovery: ... (msdn.microsoft.com)[/QUOTE]

Ovo je samo deo ....
google je nas prijatelj !

[ X Files @ 11.09.2005. 19:46 ] @
Kad proucis teoriju, pogledaj gde se sta koristi u praksi, npr kod Borland-a ( a i
drugde) svaki header ima sledecu strukturu:

#ifndef NekiFajlH
#define NekiFajlH

#include <prvi.h>
#include <drugi.h>
// itd...

// class { ... }

#endif

Zasto?
[ _alokiN_ @ 14.09.2005. 16:44 ] @
Citat:


Code:
#ifndef NekiFajlH
#define NekiFajlH

#include <prvi.h>
#include <drugi.h>
// itd...

// class { ... }

#endif


Zasto?


Tako izbegavas da deklarises klasu/promenljivu/makro vise puta.
[ leka @ 15.09.2005. 12:40 ] @
Pocni od ovog URL-a: http://www.cplusplus.com/doc/tutorial/tut5-5.html .
[ danio @ 15.09.2005. 13:13 ] @
Nekada je define bio koristen u razlicite svrhe. Cesto kao zamjena za "inline" procedure. Ali u suvremenom svjetu se sve manje koristi, radi postekoca kod debuggiranja programa koji ga previse koriste.

#if, #endif, #ifdef i #ifndef su cesto koristeni kod odjeljivanja debug koda, ili koda ovisnog od platforme, gdje je vazno da izbor razlika koje su ukljucene u program budu unsene za vrijeme kompilacije.

Ima jos nekoliko direktiva koje su ovisne od kompilatora, posebno u Borlandu...
[ X Files @ 15.09.2005. 13:52 ] @
if/ifdef/endif se mogu elegenatno koristiti kod komentarisanja vecih blokova koda,
koju u sebi vec imaju oba nacina komentarisanja, tj i //... i /*... */

#if 0
//
// COMMENTED
//
#endif


A njihova klasicna primena je i kod dodavanja pijedinih podsistema koji su u
fazi razvoja, a jos uvek nisu zreli za release:

// negde na centralizovanomestu:
#define NOVI_PODSISTEM

// u kodu:
#ifdef NOVI_PODSISTEM
//
// PUNO NOVOG KODA
//
#endif




[Ovu poruku je menjao X Files dana 15.09.2005. u 14:53 GMT+1]
[ Dragi Tata @ 15.09.2005. 13:59 ] @
Makroi se koriste i za neke moderne tehnike programiranja, pa ih ne bih baš otpisao:

http://boost-consulting.com/tmpbook/preprocessor.html
[ X Files @ 15.09.2005. 14:10 ] @
Citat:

[...] pa ih ne bih baš otpisao:

Da. Ovo me podseti na nesto sto sam gledao na TV-u:

Bil Gates kuca komandu 'Exit' i izlazi iz MS-DOS konzole, cime je simbolicno
raskrstio sa 'starudijom' i otvorio vrata Windows nacinu razmisljanja...

Koliko mi je poznato, konzolnog nacina prevodjenja slozenih projekata jos se niko
nije zvanicno odrekao i obilato se koristi...

Znam da Borland za novi BCB sprema jos jaci set komandi za kompajliranje iz
komandne linije...