Sign in to follow this  
pavel989

... as a param?

Recommended Posts

from nehe tutorial number 13:
GLvoid glPrint(const char *fmt, ...)// Custom GL "Print" Routine

i get "warning C4793: 'glPrint' : function compiled as native : 1> varargs not supported under /clr" what does that mean, and what does the ... mean?

Share this post


Link to post
Share on other sites
It's a variable argument list, it's pretty weird when you first get into it.

http://www.cprogramming.com/tutorial/lesson17.html

Share this post


Link to post
Share on other sites
Quote:
Original post by pavel989
oh wow, that's a really kool feature. TY


It's a throwback to older days, and it has been the source of a *lot* of bugs.

Newer code should generally use chained stream operators.

When you do need to use it, you must be very careful to ensure that the parameters in your string match the additional parameters in the ... section. Failure to do so can cause your program to crash or worse.

Share this post


Link to post
Share on other sites
yeah i know, but i came to c++ from c#, and came to that from python/ruby. so im kind of used to being fairly consistent with that. But for small scale applications, i think it'd be fine. But I'd expect it to be discouraged.

Share this post


Link to post
Share on other sites
You know, that message suggests you are compiling with /clr which, if you are interested in doing C++ development (as opposed to C++/CLI for managed/unmanaged interop code) you probably do not want enabled. Did you intend to create a CLR project?

Share this post


Link to post
Share on other sites
It is worth noting though that the '...' in C [and thus by extension, C++, but it started in C] isn't exactly what would be considered a good feature to use since C++ introduced much nicer mechanisms to handle what '...' was designed to deal with. If you're making language choices based on your intention to use the '...' style of parameter passing, then perhaps you should reconsider your use for it to see if there is a less error-prone and more friendly mechanism to accomplish what you want to do. There are other reasons to not want to use C++/CLI, but if you are making the choice to hold onto the '...' in old C code, it sends up a bit of a red flag.

Share this post


Link to post
Share on other sites
Quote:
Original post by Drigovas
C++ introduced much nicer mechanisms to handle what '...' was designed to deal with.

And this trend continues in C++0x with the introduction of std::initializer_list.

Share this post


Link to post
Share on other sites
i dont think i wanna work with CLI, and i was just noting that that's an interesting feature, but i don't think i will use it.

thanks for all the responses!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this