10

I've seen several questions concerning GCC's __attribute__s tagged with . That tag is described as

The attributes tag should be used for any issues relating to a property of an object, element, or file, etc.

The use of this tag in such questions seems unclear at best.

Would a new tag (e.g., gcc-attributes) be more appropriate, especially considering the suggestion that the tag be deleted?

10
  • 16
    the use of the attributes tag in general seems "unclear at best"
    – Kevin B
    Aug 18, 2022 at 14:59
  • 8
    I propose a better title: Is the [attribute] tag appropriate f̶o̶r̶ ̶G̶C̶C̶ ̶_̶_̶a̶t̶t̶r̶i̶b̶u̶t̶e̶_̶_̶'̶s̶?̶
    – VLAZ
    Aug 18, 2022 at 14:59
  • 3
    Can we not create a tag for every keyword. The declspec tag is already rather unnecessary and has no usage guidance.
    – vandench
    Aug 18, 2022 at 14:59
  • 1
    @vandench sadly, this choir isn't very receptive to that preaching.
    – Braiam
    Aug 18, 2022 at 16:51
  • 4
    Why is the [declspec] tag "rather unnecessary"? It seems like a great tag to me. It lacks usage guidance because no one has submitted it yet. That doesn't make it a bad tag. Heck, most of the good tags have terrible usage guidance, often plagiarized from various sources on the web. You don't judge usefulness or suitability of a tag based on whether someone has submitted an excerpt. The usage guidance for that one is actually kinda obvious (as with most tags). It's for programming questions about the usage of the declspec annotation. Did you really need to see that written? Aug 18, 2022 at 17:27
  • 1
    The reason I think it is unnecessary is that the majority are already related to dllexport and dllimport (44/67). That's followed up by several about alignment, which is equivalent to alignas. There are a few about uuid, property, thread (thread-local-storage), novtable, and nothrow (noexcept). With the remainder mostly being mistagged. I'd be more in favor of your suggestion of just also tagging attributes as that is an apt descriptor for most C/C++ compilers as well as C++11.
    – vandench
    Aug 18, 2022 at 18:24
  • Ah, I see. Thanks for clarifying, @vandench. That logic makes much more sense to me. Although it also reveals that it's not really the tag itself that you think is pointless. Possibly, yes, dllexport, dllimport, and declspec could/should be merged together (definitely the first two). Legacy MSVC compiler-specific annotations didn't use the "attribute" terminology, so that makes it much less discoverable, and I would also hesitate to mix in all of the MSVC-specific stuff with either GCC-specific stuff or new C11/C++11 standard attributes. Aug 18, 2022 at 21:07
  • 1
    The reason I grouped all of them together is that Clang actually treats all of them the same way. There are some minor differences in parsing, such that a __declspec won't work on linux, but after the initial parse they're all interacted with the same way in the AST. Though I can absolutely respect that most people might not realize that they're pretty much all the same construct.
    – vandench
    Aug 18, 2022 at 21:58
  • Is a recursive pun lurking somewhere? Aug 18, 2022 at 23:35
  • Before considering if [attributes] is appropriate in an specific context, the first question is if [attributes] is appropriate at all. The answer is no. It's way too generic. Anything can have attributes after all.
    – Braiam
    Aug 20, 2022 at 12:36

2 Answers 2

9

The tag doesn't seem to add anything meaningful to such a question. You might as well just tag it and that will be enough.

There is however a tag which appears to be created specifically for the purpose of gcc attributes. The only problem is that gcc also uses __attribute__ for variables and no tag for variable attributes exists.

So if any tag should be created, it should be a corresponding and the tag wiki for the two tags needs to be written. Though I think and would be less ambiguous names.

Sources to use in this case would be the friendly manual, found here:
https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
https://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html

3
  • I'm not sure collecting all GNU C __attribute__s under one tag is even useful. Or grouping variable and function separately. Variable/type attributes like __attribute__((packed)) on a struct is unrelated to __attribute__((section (".text"))), weak, or __attribute__((visibility ("hidden"))) or other linker stuff, vs. __attribute__((vector_size(16))) for SIMD, and those are all variable attributes except visibility. Attributes that go together (relevant for the same problem) might be both variable and function, e.g. ones like ELF hidden visibility for shared libs. Aug 21, 2022 at 2:21
  • 1
    But if we do want a tag for it, I think if someone is going to be an expert in GCC attributes in general, they wouldn't make a distinction between function and variable, so probably better to collect them together. Also, question volume is low enough that we probably only want one tag for all GNU C __attribute__ things, not trying to subdivide. Aug 21, 2022 at 2:24
  • 1
    It's only useful for helping future searchers find stuff if it's consistently tagged on all questions where it might be relevant, and there's a 5 tag limit, so only needing one tag is better. For folks to find new questions to answer, again grouping is also fine. (And having a specific tag does help with that, since you can watch for new questions in a bunch of tags more easily than [x] or [y] or ([gcc][attributes]) if that even works to avoid pulling in the millions of [attributes] questions. Aug 21, 2022 at 2:26
4

Yes, using the tag to refer to attributes in GCC is valid usage.

We don't need a tag because questions can have multiple tags: .

5
  • 8
    Isn’t it an ambiguous / context-dependent tag in that usage? The meaning of attributes depending on the other tags: gcc + attributes is very different from file + attributes or class + ` attributes`, etc. I get the feeling this fails tag removal tests #4 and (partly?) #1
    – Cimbali
    Aug 18, 2022 at 21:39
  • @Cimbali: Indeed, [c][attributes] finds some questions about GCC attributes, some about file attributes. So perhaps unlike Should [local-functions] be a synonym of [nested-function], or do C# local functions warrant a separate tag?, we don't have a situation where using two tags can reliably disambiguate. However, traffic is low enough that we're probably fine. Also, the other usages of the [attributes] tag are less similar in meaning, so a hypothetical gold badge in the tag might be even less meaningful than usual. Aug 19, 2022 at 4:00
  • 5
    Another problem is that GCC isn't the only compiler supporting the GNU dialect of C and C++. Clang and ICC support most of the same __attribute__((noreturn)), __attribute__((const)), __attribute__((section(".text"))), __attribute__((target("avx"))) and so on. But if we made a [gnu-c-attributes] tag, IDK if many people would find it. Again being low traffic means we don't need to solve the problem. 79 questions tagged [attributes] [c], vs. 12,556 questions tagged [attributes] so it's a tiny corner of the tag. Aug 19, 2022 at 4:04
  • (80 questions tagged [attributes][gcc]: stackoverflow.com/questions/tagged/attributes+gcc) Aug 19, 2022 at 4:05
  • We should either expand the function-attributes tag I just found, or if following the advise by this answer, burn it. I personally don't think attributes is a good tag for any purpose.
    – Lundin
    Aug 19, 2022 at 9:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .