C++ preprocessor conditional parameter

前端 未结 4 791
抹茶落季
抹茶落季 2021-01-18 08:12

Please note C++03! any C++11 solutions are not good for me, but do post them just for knowledge sake.

I know the preprocessor can do things like:

#de         


        
4条回答
  •  后悔当初
    2021-01-18 09:01

    Some answers here were better than others. The one I accepted was posted by Christian Kiewiet in a comment, but it was the most accurate for my purpose. Here is the expanded version:

    useCases.h

    enum UseCases{
        useCase1=0,
        useCase2,
        useCaseNumber//always last for iterations
    } 
    

    specializer.h

    #include "useCases.h"