473,396 Members | 2,010 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,396 software developers and data experts.

Use preprocessor in header

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
Jun 27 '08 #1
2 1154
Bryan Parkoff wrote:
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?
Yes, if you want the compiler to include the header files.

What about pragma?

Yes, what about pragma?
--
Thad
Jun 27 '08 #2
Bryan Parkoff wrote:
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?
Some compilers have options for creating and using precompiled headers.
Also you can skip the preprocessor stage in many compilers, but the
details of how to do that are compiler specific. You'll need to ask in
group for your compiler or platform.

<snip>

Jun 27 '08 #3

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

Similar topics

4
by: Jakob Simon-Gaarde | last post by:
Some project includes files from different libraries lib1,lib2 and lib3 all having each there own version header file. I need to be able to pick up these values in a single define value...
12
by: Florian | last post by:
Hi, I'm hoping that someone can point me into the right direction here. I'm trying to gain a bit of a better understanding on how the preprocessor works - something that seems like a simple...
5
by: Vittal | last post by:
Hello All, I have one doubt. I got the preprocessor output of registry_servd.c (one of the source files of my application). In the preprocessor out I see the "defination" of __sigismember...
13
by: seemanta dutta | last post by:
Greetings C gurus, I have used preprocessor directives since a very long time. But whenever I see some professional piece of C code, the linux kernel for example, I get literally confused by the...
2
by: Paolo | last post by:
I imported a VC++6.0 project into VC++7.1. The conversion operation makes a mess with Preprocessor Definitions, adding a "$(NoInherit)" for each file. For example: I had a DLL project in VC++6.0...
32
by: spibou | last post by:
Is the output of the C preprocessor deterministic ? What I mean by that is , given 2 compilers which conform to the same standard, will their preprocessors produce identical output given as input...
14
by: dan | last post by:
I would like to have the preprocessor automatically generate the number of array elements requested. Each element is zero. The elements get pasted into a larger array. The other elements may be...
36
by: anon.asdf | last post by:
Hello! Can the proprocessor make conditional decisions. Here's an example of the functionality (not standard C!) #define PUT_BYTE(const_index, val) \ #preprocessor_if (const_index ==...
3
by: Nathan Moinvaziri | last post by:
I am wonder if there is a way to use preprocessor definitions to expose code only if a particular file is included in a project. I am targeting the msvc. I am thinking of something like #if...
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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.