Code::Blocks Forums

User forums => Help => Topic started by: Zeus_ on November 06, 2020, 11:10:17 am

Title: Creating an abbreviation that expands to some code which uses C++ [[attribute]]
Post by: Zeus_ on November 06, 2020, 11:10:17 am
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) { ... }

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

Code
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?
Title: Re: Creating an abbreviation that expands to some code which uses C++ [[attribute]]
Post by: stahta01 on November 06, 2020, 11:16:02 am
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 (https://en.cppreference.com/w/cpp/language/attributes/maybe_unused)

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

Tim S.