Is it possible to somehow overload functions in C

1

I am in doubt about C. I have already programmed a time in C in procedural programming, but for some months I started to program object oriented. In Java, it is possible to overload functions. As Java is an object-oriented language that was developed based on the C language. I imagine that somehow it is possible to overload functions, just as I can in Java, as it is very useful to me.

    
asked by anonymous 02.05.2018 / 04:49

2 answers

2

Yes, it is possible.

  • through complex macros and codes ( example )
  • through some external tool
  • creating a name pattern to facilitate
  • use _Generic() available in C11
  • Create a dynamic system of variables

It has limitations, it gets ugly, I do not recommend it, but it's possible.

    
02.05.2018 / 06:05
1

In C, no. In C ++, yes. You can develop in "C" and compile as C ++ just to use the C ++ features that interest you, in the case of overloading function.

    
02.05.2018 / 05:30