|
|
Subscribe / Log in / New account

Should “count” be quoted?

Should “count” be quoted?

Posted Jul 18, 2024 3:08 UTC (Thu) by songmaster (subscriber, #1748)
Parent article: Silva: How to use the new counted_by attribute in C (and Linux)

In Jon’s 2023 article he showed a different attribute name and the count member name in quotes inside the attribute:

__attribute__((element_count(“count”)))

The online GCC and Clang documentation only mention counted_by and no sign of the quotes, so did the compilers agree on a better name while implementing this?


to post comments

Should “count” be quoted?

Posted Jul 18, 2024 4:54 UTC (Thu) by Tarnyko (guest, #90061) [Link]

This extract of the article will likely answer your question:

#if __has_attribute(__counted_by__)
# define __counted_by(member) __attribute__((__counted_by__(member)))
#else
# define __counted_by(member)
#endif


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds