Create enum from a c++ file at compile time

532 Views Asked by At

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.

1

There are 1 best solutions below

0
Zig Razor On

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.