I have a lot of code that uses C style variable arguments. The code passes in a variable called end at the very end of our variable length function calls. And…. the code also has an enumerator called end. So far they haven’t clashed (compiler error says it has an ambiguous definition: It won’t tell me where the mysterious second ‘end’ is defined) until I changed to the VC 10.0 compiler (VS 2010).
So is end some sort of reserved keyword used especially in variable args?
I know very little about them. But I’ve looked at tons of documentation on variable arguments, as well as searching here, and found nothing (which could be a good thing). So I would guess the answer is that end is not a special word used with varargs. Can I get someone to confirm this?
No — C doesn’t define
endas having any special meaning with varargs. When you write a function that takes a variable argument list, it’s up to you to decide how to tell it how long of a list has been passed. Some popular ones are that the first argument specifies (at least indirectly) how many more arguments there are, and passing a “sentinel” value (e.g., NULL) after all the others. For a couple of examples,printfdoes the former,execlthe latter.