digitalmars.D - stdc autoconfig through precompiling
- Fawzi Mohamed (47/47) Jan 29 2009 Stdc has many constants that are hardcoded. This is fragile and ugly to
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (5/14) Jan 29 2009 Did you look at what gphobos is doing for gcc.config.* ?
Stdc has many constants that are hardcoded. This is fragile and ugly to port to new platforms. The c preprocessor normally has always the correct values, and so the best thing would be to take them from it. This is my strategy: add tango.stdc.constants.* modules. These modules contains *only* enums and version statements and are generated from files that get preprocessed. In particular the exact command is *\"/ d' -e 's/__XYX__//g' basically I preprocess them, get rid of the initial part (before xxx start xxx) and remove any __XYX__. so for example ------- #include <unistd.h> xxx start xxx enum __XYX__STDIN_FILENO = STDIN_FILENO; ------- becomes ------- enum STDIN_FILENO=0; ------- I think this has still all the power of preprocessor configuration (just use a static if to query a constant), is still well packaged and self contained. I began to do the first step toward this, look in the latest tango trunk in tango/lib/constants . At the moment it is not yet used, but I wanted some help from people on various platforms: please run the dppAll.sh script and tell me problems, suggest improvement (I am interested in particular at the resulting files in tango/lib/constants/current, if some constants are not defined, if some problems crop up). Windows is not yet really solved, I was thinking to preprocess them once by hand, and then put the files in the tango/lib/constants/win directory, and on windows simply copy those files, but if some windows guru finds a way to make it work always also on windows please tell me. I think that it could improve much reliability and ability to use the newest features of a system if available without polluting the build process with many -version... I think Sean is taking a "let's wait and see" attitude toward this, kind of test it and if it is really good it will go in druntime (Sean just tell if misrepresented your opinion). Anyway that was to say that also phobos users are encouraged to contribute if they think that it will be useful... so help out and suggest improvements, correct errors,... Fawzi
Jan 29 2009
Fawzi Mohamed wrote:Stdc has many constants that are hardcoded. This is fragile and ugly to port to new platforms....I think Sean is taking a "let's wait and see" attitude toward this, kind of test it and if it is really good it will go in druntime (Sean just tell if misrepresented your opinion). Anyway that was to say that also phobos users are encouraged to contribute if they think that it will be useful... so help out and suggest improvements, correct errors,...Did you look at what gphobos is doing for gcc.config.* ? http://dgcc.svn.sourceforge.net/viewvc/dgcc/trunk/d/phobos/config/ --anders
Jan 29 2009