gerryg400 wrote:h0bby1, does this work for all platforms and all ABI's ? For example, the stdarg ABI for x86_64.
i made my own abi anyway, i use a tool to convert so and dll to my own abi, and it also correct name mangling to have unified name accross the two system, and i don't really use std arg either, but if i did, i'd recode the whole thing to be compiler independant, for now it works well if i compile under linux and window with either native gcc, icc, or visual studio
i really don't want to depend on any compiler specific thing, because it become to bothering to handle otherwise if you need to manage builds made with different compilers, i had too much issue in the past with devcpp/code warrior/borland/visual studio(s!)/cygwin etc , i tested this system before with other project and normally it should work fine with any compiler, and can link any module compiled with any compiler with any other module compiled with any other compiler
there can still be issues with c++ with how the class pointer is passed, and i don't use x64 either, but if calling convention declaration are consistent normally it doesn't make any problem as name mangling for import/export are unified with the tool to create my abi
i always consider stdargs and stdio to be very weak any way and can make many many security problem if they are not handled well so i'd rather get rid of them all together =)
for regular io , file/socket etc i'd rather have something on the line of the windows system with the overlapped structure, with asynchronous transfer management, and something more modern than stdio function, and for the printf etc that use stdarg i'd rather not use them at all
if i really needed to implement something like stdargs, i'd rather do something like an explicit typed parameter list rather than stdarg/stdio
but i guess stdarg thing must be compiler dependent anyway , not sure if there is standard way it's supposed to be handled, but if i needed to have the standard c implementation, i'd rather look at how the compiler handle it, and make the code to gather it, eventually with preprocessors switch or compiler specific version of the file that handle the stdarg functions if there are really stdarg code that cannot be avoided, but i wouldn't like that a lot cause there would be big chance to break inter compiler compatibility, or would need to keep track of the specific stdarg used in the call to handle it correctly, but it's a system that is too messy and too weak with typing for that i really want to use that
if there is a file that use stdard compiled as64 bit with gcc that need to call a function using stdard compiled with 32 bit with visual studio, it would be hell to handle correctly, so no thanks for me lol
in the absolute, it could be done by making some check by finding the calling module from the return address, and determining which kind of stdard it use, each module could be compiled with an exported symbol set automatically from compiler flag from preproc definition, the called function could gather it to determine how the stdarg were passed, if i really needed to implement some stdarg i'd probably go that way, unless there is an easy and reliable way to determine automatically how the args were passed or to force the compiler to pass it in a certain way using calling convention specifier in the function definition
it might seem like olalala, if i don't handle it correctly it will break everything and so i'd rather rely on compiler built in, but actually if you don't handle that correctly (arg passing etc) , it will break once you change a compiler flag or change compiler, or it need to be draconian on the compilation options, and that everyone who want to build anything for the os use the exact same cross compiler compiled with exact same options, which is a constraint that i'd rather avoid all together
with this system it introduce a little bit of specific base C function naming , but that can easily be dealt with using preprocessor definition, and after you don't have to care at all about any compiler specific thing at all, and it can be compiled using any compiler with zero #ifdef all expect for calling convention and function delcaration attributes
in theory it can use the runtime linked statically if needed , it shouldn't hurt, except it increase the exe size a little bit, and then can lead to problem if you want to link statically module compiled with different compiler together, it shouldn't be a problem in the case of os dev, as it's unlikely someone will have to link statically with a precompiled lib, but without the runtime at all, it can even link static lib compiled with any compiler together without pb, provided the linker can understand the format of the objects, like compiling some static lib with different version of gcc or different compiler that can output static .lib files