Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#Define Entire function call with arguments?

I have a program that I am running on two different compilers, and each compiler has a different file handling library. For example on library requires:

fwrite(buffer,size,elements,file)

While the other is:

f_write(file,buffer,size,elements)

is there anyway I could use a global #define in my main header file inside of a #ifdef statement that would allow me to seamlessly transition between compilers?

like image 799
PumpkinPie Avatar asked Jun 24 '26 00:06

PumpkinPie


1 Answers

Sure:

#ifdef STUPID_COMPILER
# define fwrite(ptr, size, nitems, stream) f_write(stream, ptr, size, nitems)
#endif

Then just use fwrite() in your code -- no wrapper function needed. The preprocessor will translate it to an f_write() call if you're using the compiler/library that requires that.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!