User forums > Help

Creating an abbreviation that expands to some code which uses C++ [[attribute]]

(1/1)

Zeus_:
I'm trying to create an abbreviation that expands to some code containing the [[maybe_unused]] attribute in C++. However, this triggers the Script Expansion feature of C::B Abbreviations, which happens to use the [[]] operator for its functionality.

Take this code as an example for an abbreviation.


--- Code: ---void func ([[maybe_unused]] int n) { ... }

--- End code ---

When activating the abbreviation using Ctrl+J, this gives:


--- Code: ---Script Run Error

Filename: CommandLine
Error: the index 'maybe_unused' does not exist.

--- End code ---

How do I use an abbreviation that expands to code containing something of the form [[cpp_attribute]] without triggering script expansion?

stahta01:
Not a reply to the OP; Link to docs about C++ attribute: maybe_unused (since C++17)

https://en.cppreference.com/w/cpp/language/attributes/maybe_unused

Edit add second link https://en.cppreference.com/w/cpp/language/attributes

Tim S.

Navigation

[0] Message Index

Go to full version