Author Topic: Creating an abbreviation that expands to some code which uses C++ [[attribute]]  (Read 1804 times)

Offline Zeus_

  • Single posting newcomer
  • *
  • Posts: 4
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.

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

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

Script Run Error

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

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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7192
    • My Best Post
Not a reply to the OP; Link to docs about C++ attribute: maybe_unused (since C++17)

Edit add second link

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
When in doubt, read the CB WiKi FAQ.