I have a scenario where I have a variety of C++ files with a specific macro:
__EXTERNALIZE(Name, File)
This macro is empty, it does nothing. But I want to write an external tool that scans one or many input files for this macro and do something once it finds that.
To clarify, here is a bit of pseudo-c:
typedef struct {
char* varname;
char* filename;
} MacroInfo_s;
FILE* fh = fopen("./source.cpp",'r');
while(read_untill_macro(fh) && !feof(fh)) {
MacroInfo_s m;
fill_macro_info(&m, fh);
// Do something with m.varname and m.filename
}
C++11 isn't broadly available. For instance, VS 2010 does not provide it at all, and that is the lowest I want to target on the Windows side. On my OS X 10.10, everything is fine. That is also why I mainly don't want to use Regexp, since I would need an extra library. And that just to react to a single macro within a few files seems a bit of an overkill.
What would be a good aproach to make this possible to work?
Aucun commentaire:
Enregistrer un commentaire