Meta-programming question
-
So, does anyone here have any cool tricks for being able to use constants across disparate languages/enviroments? For instance, what if I have some constant I'd like to use in both C++ and Java, but don't want to have to duplicate? Or even between code and build environment (e.g., C++ and makefile/project file, or between Java and an ANT file)? The problem, of course, with duplication is that if it changes in one spot you have to change it in the other. But I wonder if there are any better solutions? (Looking mostly for generic ideas, not so much specific implementations.) An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
-
So, does anyone here have any cool tricks for being able to use constants across disparate languages/enviroments? For instance, what if I have some constant I'd like to use in both C++ and Java, but don't want to have to duplicate? Or even between code and build environment (e.g., C++ and makefile/project file, or between Java and an ANT file)? The problem, of course, with duplication is that if it changes in one spot you have to change it in the other. But I wonder if there are any better solutions? (Looking mostly for generic ideas, not so much specific implementations.) An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
You can use an external source for such constants. INI files, environmental variables, etc. Something all of your tools can or can be made to understand.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades. I don't know what you thought; I'm not your astronaut...
-
You can use an external source for such constants. INI files, environmental variables, etc. Something all of your tools can or can be made to understand.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades. I don't know what you thought; I'm not your astronaut...
That's certainly a workable idea... and I've used it in some situations, but I'd like to find some scheme of doing it at compile-time. I suppose some custom build tools or something, that can generate code from an INI file might work... hmm... An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
-
That's certainly a workable idea... and I've used it in some situations, but I'd like to find some scheme of doing it at compile-time. I suppose some custom build tools or something, that can generate code from an INI file might work... hmm... An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
AFAIK, most C/C++ compilers and make utilities allow environmental variables to define symbols used in code. Not sure about Java or anything else though.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades. I don't know what you thought; I'm not your astronaut...
-
AFAIK, most C/C++ compilers and make utilities allow environmental variables to define symbols used in code. Not sure about Java or anything else though.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades. I don't know what you thought; I'm not your astronaut...
Yes, I have seen (at least in Visual C++) ways of turning an environment variable into a #define. And I've seen ways of getting Ant to be able to suck in a INI-like name=value file to make constants for it. But I can't think of any cross-language way to do any of that... aside from writing some tools of my own, I guess. An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
-
So, does anyone here have any cool tricks for being able to use constants across disparate languages/enviroments? For instance, what if I have some constant I'd like to use in both C++ and Java, but don't want to have to duplicate? Or even between code and build environment (e.g., C++ and makefile/project file, or between Java and an ANT file)? The problem, of course, with duplication is that if it changes in one spot you have to change it in the other. But I wonder if there are any better solutions? (Looking mostly for generic ideas, not so much specific implementations.) An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
An Idea grown out of the actual survey: How about a Code Generator that builds the different files for the various languages? (haven't tried it for myself, so don't ask for a code generator that works for c++, java and [add your favorite programming language here] ) Greets Roland
Wenn Du diesen Satz irgendwo liest, ignoriere ihn.
-
So, does anyone here have any cool tricks for being able to use constants across disparate languages/enviroments? For instance, what if I have some constant I'd like to use in both C++ and Java, but don't want to have to duplicate? Or even between code and build environment (e.g., C++ and makefile/project file, or between Java and an ANT file)? The problem, of course, with duplication is that if it changes in one spot you have to change it in the other. But I wonder if there are any better solutions? (Looking mostly for generic ideas, not so much specific implementations.) An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
Actually if I'm not mistaken, the .NET framework already has to do something like that. It supports round about 20 languages, I suspect that compiled files like dll's or exe's should be able to 'talk' to each other if necessary regardless of the language they're written in. The first thing that comes up is serialization, XML, .... maybe you can look in to webservices? How do you do it there? good luck. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
-
An Idea grown out of the actual survey: How about a Code Generator that builds the different files for the various languages? (haven't tried it for myself, so don't ask for a code generator that works for c++, java and [add your favorite programming language here] ) Greets Roland
Wenn Du diesen Satz irgendwo liest, ignoriere ihn.
actually, I'm at something that would allow this - but I should keep my mouth shut for premature talking annoys the project gods... Welchen Satz?
I never really know a killer from a savior
boost your code || Fold With Us! || sighist | doxygen