简体   繁体   中英

Create enum from a c++ file at compile time

I have some functions that can be defined by users like :

int prop1(....) {
  if(...)
    return Prop2;

   return Failed;
}

int prop2(...) {
  if(...)
    return Prop3;

  return Failed;
}

I want to create a file if the dependencies between the different functions.

Is there some way to generate a Enum at compile time and parse the file with some kind of regex to extract the different return tokens in a function and write it to a file.

It is not possible to create an enum at compile time.

You can parse the file before and create a file.h from it so that you can include it in your program, but nothing else.

Obviously you can automate this mechanism with a script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM