   Invoke Preprocessor on Text Files during Run Time
  hi,I'd like to preprocess a text file dynamically - just basic handling of #define, #include, #ifdef. Nothing fancy - but it has to be dynamic, not compile time. The ideal solution would be a call that would work with the free visual studio express edition. I think in Unix people use a cpp command to send in the input file and get the output file back - that would be perfect.For this particular project, the simplest solution would be best. I'd like to be able to make this project available to beginner programmers and not ask them to download or work with a 3rd party package. Perhaps I'll just have to implement a simple preprocessor but if there is a way to invoke the microsoft precompiler directly I'd love to know. I can't find this call if it exists.thanks very much for any advice.   
/P (Preprocess to a File) (C++);  Maybe it would be best if you told what the overall goal is.  It sounds to me like you want dynamic configuration or script files.  If that's the case, you might want to use a scripting language like Lua or write a simple parser yourself.The problem with the C preprocessor is, your program that uses the C preprocessor directives won't be portable.  The preprocessor code is not part of the runtime library (or at least I really don't think it is), so anyone wanting to run the program will need Visual Studio.  One possible workaround is to distribute an open source C preprocessor (like the one from GCC) with your program.   ;  hi,thanks for your quick replies.Oluseyi, I may not have understood - but I don't see a way to use the /P option to allow dynamic preprocessing of files. In this particular case, I need to preprocess a text file after the program is running. Hopefully I have not missed the obvious.jonahrowley, I hope I can be more helpful with specifics - I'm writing a molecular dynamics simulation. There is an excellent open source project called Gromacs which is sophisticated and complex, not an easy step for beginners. My program is designed to illustrate the fundamental aspects of molecular dynamic in a more interactive user friendly way, and serve as a first step towards understanding how simulations like Gromacs work. It turns out that Gromacs uses preprocessed text files to import data. I'd like my program to integrate with that format so I need to find a way to import those files without modifying the format. It's a small aspect of what I'm doing, so I was hoping there would be a simple way to invoke it - even if I go with a better option later it would be nice to have a quick fix. I would want users to be able to modify text data files while the program is running so i need to process them each time they are opened.Gromacs is Unix. My target audience would be students who have probably had little or no programming experience. It's likely they have never used Unix so a PC package is probably most helpful. Also, many users will not actually work with the code, just the final executable. I am reluctant to give up the portability, so I'll probably implement a simple preprocessor at some point - I don't think I need any directive apart from #include which is straight forward, and the #define and #ifdef commands - which will take a bit longer - I am just interested in other aspects right now and hoping a quick fix is available.I realize this is not specifically a game question, but I was thinking script programmers would have the most insights into questions like this. Also, the project is certainly very game-like in structure, and will be open source when I'm done, so maybe some game programmers can find it useful since it will demonstrate many essential components of games.thanks again for your support. ;  That is the beauty of open source.Grab the latest source release From  Their SiteExtract the fileGo to src/kernel/Open grompp.cBoom, you have their code for preprocessing their file format. Hard to be any more compliant than that.It is GPL so there are restrictions with that, but it didn't sound like you were trying to sell/package it into your own/yada anyway.;Quote:Original post by zapharaOluseyi, I may not have understood - but I don't see a way to use the /P option to allow dynamic preprocessing of files. In this particular case, I need to preprocess a text file after the program is running. Hopefully I have not missed the obvious.Calling the Visual C++ compiler with the /P option makes it behave like cpp would. Since you know how to solve your problem using cpp (as you mentioned in your original post), using the compiler to "simulate" the behavior of cpp on Windows should solve the problem there as well.;  I'll need to look into the Gromacs some more - I found there is a Visual Studio version of it and there is a specific method for the preprocessor so I'll look into that.I haven't used the gcc before, but I'll check into the /P option as well.I do appreciate the assistance.thanks,Mike   