using C++11 attributes

前端 未结 2 758
抹茶落季
抹茶落季 2020-12-16 13:14

Could you please explain how to get information from attributes in C++? For example, I want to write C++ to python binding. For this I need to annotate all methods in class

相关标签:
2条回答
  • 2020-12-16 13:42

    An update with some more recent information:

    GCC now (as of 4.8) implements C++11 attributes as an alternative syntax for __attribute__((XXX)).

    You can also use the GCC plugin mechanism to define new attributes - see https://gcc.gnu.org/onlinedocs/gccint/Plugins.html.

    You can also do this in python using the gcc-python-plugin - see https://gcc-python-plugin.readthedocs.org/en/latest/attributes.html.

    0 讨论(0)
  • 2020-12-16 13:43

    Attributes (a new C++11 feature) are just a standardized syntax for compiler extensions. To do what you want you would need a compiler with the proper extensions. So far, I don't think any compiler even implements attribute syntax, much less any specific attributes for Python bindings.

    Because they're intended for compiler extensions, there's no standard way of creating your own attributes, like you can with Java annotations or C# attributes. Of course, a compiler could provide this ability as an extension... ;)

    0 讨论(0)
提交回复
热议问题