Googles appar
Huvudmeny

Post a Comment On: cbloom rants

"03-13-09 - Automatic Prefs"

6 Comments -

1 – 6 of 6
Blogger castano said...

That's why I like cmake, it can generate projects automatically, so that you don't have to edit project settings manually.

For example, for Qt apps that need the Qt objects to be preprocessed you would write:

qt4_wrap_cpp(preprocessed_files ${files_to_preprocess})
add_executable(name ${other_files} ${preprocessed_files})

Here we add the preprocessed files to the build. A common alternative is to include them from the cpp file:

#include "preprocessed_file.moc"

Another option is to use a different extension for the files that you want to have preprocessed, and create a custom rule for them, but that may not work on older version of visual studio.

March 13, 2009 at 10:41 PM

Anonymous Anonymous said...

Yeah, makefiles are the big win for this. I have a few generated .c files in g, and they're all specified manually since I couldn't find a way to automate it in VC6, but fortunately those aren't c files, just special source files, so there's only a few. Doing it for every C file would be a huge pain.

You don't want the autogenerator to touch the original file since that fucks with timestamps, and you don't want all the autogenerated code to go in one file because that fucks with incrementality, so one output file per input file is probably the big win. (I actually generate a .c, a .h, and a .inl from my thing.)

March 14, 2009 at 2:58 AM

Blogger Brian said...

If you have the autogenerated code placed in the original file, it will make a mess of your version control. Why not just #include the autogenerated file into your files where you need them?

March 15, 2009 at 11:43 AM

Blogger Justin Paver said...

As a way to solve this problem, I always thought it would be nifty to extend the C preprocessor to be struct/class aware. eg.

void MyPref::NotAutoGen_Reflection()
{
#for_each_member_variable(M, MyPref)
REFLECT(M);
#end_for
}

March 15, 2009 at 12:49 PM

Blogger cbloom said...

"If you have the autogenerated code placed in the original file, it will make a mess of your version control. Why not just #include the autogenerated file into your files where you need them?"

Yeah, I think that's the way to go. For xxx.cpp I can include xxx.aug ; in fact seeing a cpp that includes an aug could be the trigger to run the processor.

There's another question of whether the augs should be checked in or if they should be treated like "obj" files and remade on each machine.

March 15, 2009 at 1:27 PM

Blogger cbloom said...

"As a way to solve this problem, I always thought it would be nifty to extend the C preprocessor to be struct/class aware. eg."

Yep, that is one of the few enhancements to C++ I've always wanted. If they add member iteration, typeof, and the ability to construct from a type_info (like new(type_info)) we'd be set.

March 15, 2009 at 1:29 PM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.