Hello all:
I apologize if this query seems a bit off-topic. But I couldn't think
of another place to post my message.
I would like to get an idea of how you all like to handle preprocessor
defines. Do you like to create a header file with all the associated
defines and then include it with every frickin' source file that's
created/modified, OR do you appreciate the ability to pass these on
the command line or from a makefile? Can you tell which method I
prefer?
I have been involved with some discussions on this topic, and though I
have voiced my preference (along with a few reasons to support), I
don't feel like I'm coming up with compelling reason(s) for supporting
my preference. Is this just purely subjective and wreaking of someone
having too much time on their hands? Or is there some strong reasons
for choosing one method or the other?
Thanks, in advance,
Brock 4 1752
[snips]
On Tue, 09 Dec 2003 10:04:28 -0800, Brock wrote: Hello all:
I apologize if this query seems a bit off-topic. But I couldn't think of another place to post my message.
I would like to get an idea of how you all like to handle preprocessor defines. Do you like to create a header file with all the associated defines and then include it with every frickin' source file that's created/modified, OR do you appreciate the ability to pass these on the command line or from a makefile? Can you tell which method I prefer?
Personally, I prefer a combination of the two.
Suppose I have a header, "porting.h" which contains all my system-specific
defines. Each section would, in turn, be wrapped in something like #ifdef
IS_UNIX ... #endif. Thus, to enable Unix compilation, you'd pass in a
command-line define such as -DIS_UNIX.
Why do I prefer this? Simple: I find including them in a header makes
for maximal readability and maintainability , without sacrificing the
flexibility to use a makefile to select between the options.
In <51************ **************@ posting.google. com> br******@gentex .com (Brock) writes: I would like to get an idea of how you all like to handle preprocessor defines. Do you like to create a header file with all the associated defines and then include it with every frickin' source file that's created/modified, OR do you appreciate the ability to pass these on the command line or from a makefile?
Depending on their actual purpose, some macro defintions belong to the
source code, others to the compiler command line (which basically means
to the makefile).
For example, if you want to define a DEBUG macro, the right place is
the makefile, but the definition of something like MAX_ITEMS belongs to
the source code.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de Da*****@cern.ch (Dan Pop) wrote in message news:<br******* ****@sunnews.ce rn.ch>... In <51************ **************@ posting.google. com> br******@gentex .com (Brock) writes:
I would like to get an idea of how you all like to handle preprocessor defines. Do you like to create a header file with all the associated defines and then include it with every frickin' source file that's created/modified, OR do you appreciate the ability to pass these on the command line or from a makefile?
Depending on their actual purpose, some macro defintions belong to the source code, others to the compiler command line (which basically means to the makefile).
For example, if you want to define a DEBUG macro, the right place is the makefile, but the definition of something like MAX_ITEMS belongs to the source code.
And I would say I totally agree with you. But that's the problem I say
that things like a DEBUG macro, or a BOARD_TYPE macro, or a hardware
peripheral-related macro should be in a makefile. I think we agree.
But I can't come up with a strong reason for saying so.
Brock
In <51************ **************@ posting.google. com> br******@gentex .com (Brock) writes: Da*****@cern.c h (Dan Pop) wrote in message news:<br******* ****@sunnews.ce rn.ch>... In <51************ **************@ posting.google. com> br******@gentex .com (Brock) writes:
>I would like to get an idea of how you all like to handle preprocessor >defines. Do you like to create a header file with all the associated >defines and then include it with every frickin' source file that's >created/modified, OR do you appreciate the ability to pass these on >the command line or from a makefile?
Depending on their actual purpose, some macro defintions belong to the source code, others to the compiler command line (which basically means to the makefile).
For example, if you want to define a DEBUG macro, the right place is the makefile, but the definition of something like MAX_ITEMS belongs to the source code.
And I would say I totally agree with you. But that's the problem I say that things like a DEBUG macro, or a BOARD_TYPE macro, or a hardware peripheral-related macro should be in a makefile. I think we agree. But I can't come up with a strong reason for saying so.
The strong reason is that you don't want to touch the source code in order
to build the application in a different way and you don't want to put
source code related stuff in the building procedure (i.e. the makefile).
You certainly don't want to look into the makefile in order to understand
the source code or to look into the source code in order to understand
how the application is built.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven T. Hatton |
last post by:
In the past there have been lengthy discussiions regarding the role of
header files in C++. People have been very adamat about header files
serving as in interface to the implementation. I do understand the
objective. This example may represent an interface in need of a bit of
refactoring, but it goes to demonstrate the basic idea as I understand it.
http://developer.kde.org/documentation/library/cvs-api/kdevelop/html/ast_8h-source.html...
|
by: Karthik |
last post by:
When I try to compile my VC++ program (am Using VS6.0). I get the
following error in a header file ATLCONV.H.
c:\program files\microsoft visual studio\vc98\atl\include\atlconv.h(52)
: error C2065: '_ASSERTE' : undeclared identifier
Error executing cl.exe.
and it points to
inline LPWSTR WINAPI AtlA2WHelper(LPWSTR lpw, LPCSTR lpa, int nChars,
|
by: pooja |
last post by:
Suppose i have created a class c1 with f1()in c1.cpp
and included this c1.cpp in file1.cpp file , which is also having
main() by giving the statement #include "c1.cpp".
the same i can do by using header file. i can create a class c1 with
f1() in c1.h and include this c1.h in file1.cpp by giving the statement
#include "c1.h"
tell me that what exactly is the difference between c1.h and c1.cpp?
Since they both are doing the same things.
|
by: Gregory Pietsch |
last post by:
Hello comp.lang.c enthusiasts,
Once while in a fit of pique, I thought I'd pull a Plauger. I have come
up with an implementation of the functions declared in the standard C99
header fenv.h. I thought I'd post them and get some constructive
criticism from this crowd of pedants.
First, the fenv.h header itself:
/* fenv standard header */
|
by: virgincita schmidtmann |
last post by:
Sorry for inconvenience!
I have two sourcefiles file1.c and file2.c. file1.c codes the standard BST
(binary search tree) functions declarations and the basic struct definition.
file2.c has some special functions, I want to implement for exercise
purposes.
In my opinion gcc file1.c file2.c should do the linking. But the compiler is
complaining, because it doesn't know about the struct and it's pointers
| |
by: The Cool Giraffe |
last post by:
Please note that i do intend to use a header file. However,
i'm not sure if it's really needed or just a convention.
Suppose we have the following two files.
// Something.h
class Something {
private: int number;
public:
Something ();
|
by: HT-Lab |
last post by:
Hi All,
Not strictly a C++ question but I am sure this is a common compile issue :-)
I have a generic makefile (see below) that I would like update such that if
I make some changes to a header file the associated cpp file is recompiled.
I tried using constructs like:
..h.cpp:
touch $<
|
by: Fabian Braennstroem |
last post by:
Hi,
I would like to delete a region on a log file which has this
kind of structure:
#------flutest------------------------------------------------------------
498 1.0086e-03 2.4608e-04 9.8589e-05 1.4908e-04
8.3956e-04 3.8560e-03 4.8384e-02 11:40:01 499
499 1.0086e-03 2.4608e-04 9.8589e-05 1.4908e-04
|
by: aryan |
last post by:
Hi,
I need to change the value of a const int variable defined in the
header file of a library. The variable is used to dynamically set size
of a char buffer within a class of the library. Its not used anywhere
else. It seems to work without recompiling atleast one application.
Would it work with other applications without recompiling?
thnx in advance
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |