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 DEP_PROJECT. pseudo
preprocessor code would look like this:
1. Lib1 version header is included:
#define PROJ_NAME "Lib1"
#define PROJ_VERSION 102
#define DEP_PROJECTS DEP_PROJECTS,PROJ_NAME PROJ_VERSION,
(DEP_PROJECTS = "Lib1",102,)
2. Lib2 version header is included:
#define PROJ_NAME "Lib2"
#define PROJ_VERSION 422
#define DEP_PROJECTS DEP_PROJECTS,PROJ_NAME PROJ_VERSION,
(DEP_PROJECTS = "Lib1",102,"Lib2",422,)
3. Lib3 version header is included:
#define PROJ_NAME "Lib3"
#define PROJ_VERSION 865
#define DEP_PROJECTS DEP_PROJECTS,PROJ_NAME PROJ_VERSION,
(DEP_PROJECTS = "Lib1",102,"Lib2",422,"Lib3",865,)
But can it be done somehow?
Best regards Jakob 4 1671
Jakob Simon-Gaarde posted: 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 DEP_PROJECT. pseudo preprocessor code would look like this:
1. Lib1 version header is included:
#define PROJ_NAME "Lib1" #define PROJ_VERSION 102
#define DEP_PROJECTS DEP_PROJECTS,PROJ_NAME PROJ_VERSION,
(DEP_PROJECTS = "Lib1",102,)
2. Lib2 version header is included:
#define PROJ_NAME "Lib2" #define PROJ_VERSION 422
#define DEP_PROJECTS DEP_PROJECTS,PROJ_NAME PROJ_VERSION,
(DEP_PROJECTS = "Lib1",102,"Lib2",422,)
3. Lib3 version header is included:
#define PROJ_NAME "Lib3" #define PROJ_VERSION 865
#define DEP_PROJECTS DEP_PROJECTS,PROJ_NAME PROJ_VERSION,
(DEP_PROJECTS = "Lib1",102,"Lib2",422,"Lib3",865,)
But can it be done somehow?
Best regards Jakob
Well firstly you can't have two macros with the same name... well you can,
but the second one just overwrites the first one, eg:
#define a 1
#define a 2
a == 2 now.
I'm going to assume that you've considering giving the macros different
names and for some reason didn't go with it. I suggest the following for
each included header file:
namespace Lib1 {
const char* const project_name = "Library1";
const char* const project_version = "102";
}
and then for your second header file:
namespace Lib2 {
const char* const project_name = "Library2";
....
....
... and so on.
-JKop
Jakob Simon-Gaarde wrote:
.... #define DEP_PROJECTS DEP_PROJECTS,PROJ_NAME PROJ_VERSION,
(DEP_PROJECTS = "Lib1",102,"Lib2",422,"Lib3",865,)
But can it be done somehow?
No. Perhaps using m4, but not the standard CPP.
JKop <NU**@NULL.NULL> wrote in message news:<EH*****************@news.indigo.ie>... Jakob Simon-Gaarde posted:
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 DEP_PROJECT. pseudo preprocessor code would look like this:
1. Lib1 version header is included:
#define PROJ_NAME "Lib1" #define PROJ_VERSION 102
#define DEP_PROJECTS DEP_PROJECTS,PROJ_NAME PROJ_VERSION,
(DEP_PROJECTS = "Lib1",102,)
2. Lib2 version header is included:
#define PROJ_NAME "Lib2" #define PROJ_VERSION 422
#define DEP_PROJECTS DEP_PROJECTS,PROJ_NAME PROJ_VERSION,
(DEP_PROJECTS = "Lib1",102,"Lib2",422,)
3. Lib3 version header is included:
#define PROJ_NAME "Lib3" #define PROJ_VERSION 865
#define DEP_PROJECTS DEP_PROJECTS,PROJ_NAME PROJ_VERSION,
(DEP_PROJECTS = "Lib1",102,"Lib2",422,"Lib3",865,)
But can it be done somehow?
Best regards Jakob
Well firstly you can't have two macros with the same name... well you can, but the second one just overwrites the first one, eg:
#define a 1
#define a 2
a == 2 now.
I'm going to assume that you've considering giving the macros different names and for some reason didn't go with it. I suggest the following for each included header file:
namespace Lib1 {
const char* const project_name = "Library1"; const char* const project_version = "102"; }
and then for your second header file:
namespace Lib2 {
const char* const project_name = "Library2"; ... ... .. and so on.
-JKop
The preprocessor code was pseudo-preprocessor code. But it explaines
the problem. I am seeking an automatic dependancy information
generator, so that as the version headerfiles are included a
preprocessor define is build up. This way the I can store the version
dependancy at the buildtime. whith a function like:
std::string get_dependancies()
{
return DEP_PROJECTS;
}
also pseudo!
On Thu, 01 Jul 2004 15:01:56 GMT, JKop <NU**@NULL.NULL> wrote in
comp.lang.c++: Jakob Simon-Gaarde posted:
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 DEP_PROJECT. pseudo preprocessor code would look like this:
[snip]
Well firstly you can't have two macros with the same name... well you can, but the second one just overwrites the first one, eg:
#define a 1
#define a 2
You can't do this in a program without making it ill-formed. A
diagnostic is required. See paragraphs 1, 2, and 3 of section "16.3
Macro replacement" in the C++ standard.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Pelle Beckman |
last post by:
Hi,
This might be OT...
Are there preprocessor defines in the C++ standard,
such as __FILE__, __LINE__, __NAMESPACE__, __FUNCTION__, ec?
If there is, were can I find a list?
If there...
|
by: Chris Croughton |
last post by:
Is the following code standard-compliant, and if so what should it do?
And where in the standard defines the behaviour?
#include <stdio.h>
#define DEF defined XXX
int main(void)
{
int...
|
by: ccwork |
last post by:
Hi all,
We can define some magic number with #define:
#define OPERATION_1 0x00000001
#define OPERATION_2 0x00000002
#define OPERATION_3 0x00000003
....
We can also do that with enum:
enum...
|
by: CPA Study Group |
last post by:
Is it possible to write a C Preprocessor macro which changes the case
of a string. This will save me time by not having to use awk of write
my own preprocessor. Here is a sample code which I want...
|
by: tb2000 |
last post by:
Here's my scenario: VS2005, .NET and .NETCF C# projects mices in a single
solution file, referencing the same source code base (the NETCF projects use
reflinks to the NET sources)
Now I am...
|
by: s7master |
last post by:
Is there any way I can check to see what agriculture (x86_64, ppc,
ia32, etc) I am compiling with using the preprocessor? All help is
appreciated.
|
by: Sam of California |
last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing
of the source file"?
I responded to that comment by saying that the preprocessor is not just a
pass. It processes...
|
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...
|
by: lagman |
last post by:
All,
I'm looking for a tool that is able to take my code base (which is
full of preprocessor directives) and spit out source code that is
"clean" of any preprocessor directives based on the...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
|
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,...
| |