I plan to create a library when I complete the implementation in both
header code and source code. I declare variable and function in header code
and I define variable and function in source code.
Do I truly need to use preprocessor if C Compiler does not need to
recompile unmodified header code and source code? What about pragma? I
often modify main.cpp to do more implementation while both Test.h and
Test.cpp are seldom modified.
For Example
/* Test.h */
#ifndef TEST_H
#define TEST_H
/* Declare global variable using extern or static */
/* Declare global function */
extern int a;
void do_test (void);
#endif /* TEST_H */
/* Test.cpp */
#include "Test.h"
int a = 0;
void do_test (void)
{
/* do something */
}
/* Main.cpp */
#include "Test.h"
int main (void)
{
do_test (void);
return 0;
}
--
Yours Truly,
Bryan Parkoff
header code and source code. I declare variable and function in header code
and I define variable and function in source code.
Do I truly need to use preprocessor if C Compiler does not need to
recompile unmodified header code and source code? What about pragma? I
often modify main.cpp to do more implementation while both Test.h and
Test.cpp are seldom modified.
For Example
/* Test.h */
#ifndef TEST_H
#define TEST_H
/* Declare global variable using extern or static */
/* Declare global function */
extern int a;
void do_test (void);
#endif /* TEST_H */
/* Test.cpp */
#include "Test.h"
int a = 0;
void do_test (void)
{
/* do something */
}
/* Main.cpp */
#include "Test.h"
int main (void)
{
do_test (void);
return 0;
}
--
Yours Truly,
Bryan Parkoff
Comment