Eclipse-CDT: Use Namespace in automatic generated include-guards

前端 未结 2 1011
太阳男子
太阳男子 2020-12-20 11:43

Is it possible (and how) to add the namespace in the name of the automatic generated include guards in Eclipse CDT, when creating a new class using the .hpp/.cpp templates?<

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-20 12:13

    So in the Preferences dialog under C/C++ -> Code Style -> Code Templates you can modify the template to be closer to what you need, for example if you need the namespace in the guard, you can do something like.

    ${filecomment}
    
    #ifndef ${namespace_name}_${include_guard_symbol}
    #define ${namespace_name}_${include_guard_symbol}
    
    ${includes}
    
    ${namespace_begin}
    
    ${declarations}
    
    ${namespace_end}
    
    #endif /* ${namespace_name}_${include_guard_symbol} */`
    

提交回复
热议问题