Jump to content
Sign in to follow this  
Guest bartels

How to overload functions?

Recommended Posts

Dunno really know if this here is overloading, but anyway. How can I 're'-define a function, e. g. having funct(a,:( and funct(a,b,c,d) at the same time.Just a redefinition likevoid funct (char a, char :({ bla bla}void funct (char a, char b, char c, char d){ even more bla}doesn't work for me. MinGW kicks out some errors like "previous declaration of funct" or something like that.Etienne :-wave

Share this post


Link to post
Share on other sites
Guest bartels

Try C++ not C for illegal re-definitions or what is it called "overloading?". If you want a function wth varibale parameter list try to define it with ..., but I don't recommend it. Chose different function-names and that's all, where is the problem?Arne Bartels

Share this post


Link to post
Share on other sites

Yup what I wanted was several functions with different parameters but the same function name (e. g. like most of the GDI+ functions).>Chose different function-names and that's all, where is the>problem?Nah, no problem really, just wondered if it was possible in plain C to achieve the above.Thanks,Etienne :-wave

Share this post


Link to post
Share on other sites
Guest bartels

Hm, I just remembered that in plain C it is impossible to overlaod functions as fara as I know. But, if you write C-style functions in .cpp files, function overloading is possible. Since all compilers do C++ compilation if used with .cpp files it is C++, even if the function style is still C.Arne Bartels

Share this post


Link to post
Share on other sites

Ok, thanks a lot, this might indeed work. :-) One dumb question though - how to tell the MinGW makefile to compile e. g. SDK.cpp instead of SDK.c? In the makefile there is specified GAU_NAME=SDK for example, without any file extension. Didn't really get it to compile SDK.cpp.Thanks again,Etienne :-wave

Share this post


Link to post
Share on other sites
Guest bartels

Have a look further down where GAU_NAME is really needed. Is there an extension? Fine, replace it.Arne Bartels

Share this post


Link to post
Share on other sites

WHOOOPS *hiding in corner*I better should have had a deeper look once into makefile.Along with hundred thousand new warnings about conversion sutff (not too important for now), one error though I can't seem to get fixed:somegauge.o(.eh_frame+0x11):somegauge.cpp: undefined reference to `__gxx_personality_v0'Thanks man! ;-)Etienne :-wave

Share this post


Link to post
Share on other sites
Guest bartels

Maybe a library you forgot to add to the ADD_LIBS section? I have never seen this reference before. Is it a function you defined yourself?Arne Bartels

Share this post


Link to post
Share on other sites

Hmmm, no.Seems to be just the result of changing to CPP. Also getting thousands of warnings about conversions now. That all with the overloaded functions commented out by the way.

Share this post


Link to post
Share on other sites
Guest bartels

Strange. Personally I prefer not to use "everything in one" file especially with cpp files. I posted an example of a splitted SDK sample recently here. To get it to work with GCC it needs a bit of work on the makefile, though.If I recall that right you need ADD_OBJS line like:ADD_OBJS=SDK.Attitude.o SDK.Control_Surfaces.o SDK.Fuel.o SDK.Fuel_Selector.o SDK.Temperature.o SDK.Wiskey.oI also changed $(GAU_NAME).o: $(GAU_DEPS) $(CC) $(CFLAGS) -o $@ -c $

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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...