B
Bryan Parkoff
Do C/C++ Compiler allow function to contain more than 8 parameters? I
checked MS Visual C++ 6.0 that it can only limit 8 parameters, but
most C/C++ Compiler can limit maximum 256 parameters. Can you please
verify for me?
Usually, I write function that is about 100 lines. I would need
20 parameters which they are all reference to global variable inside
struct. For best optimization, it does not require to create stack
frame because variables are always global inside struct. It is
possible that stack frame is never created because local variables are
never defined.
I like pointer to function into array that it looks like CALL
Table, but I prefer to use switch cases that it looks like JMP Table
because all functions under pointer list can't be inlined or
forceinlined, but only sub-functions can be inlined or forceinlined
inside pointer to function list.
Are you sure that pointer to function list can only limit to 1,023
while switch cases can limit to 300 or 1,023 for best optimization?
I have another problem with #define, #undef, and #ifdef directive
inside functions. I have three duplicated functions with 10 lines.
First function has 8 lines, Second function has 9 lines. Third
function has 10 lines. I prefer to use only one function so #ifdef
name and #endif will be placed on line 9 and line 10.
Most functions can have #define and #undef before it starts to
call function with 10 lines. If #undef is executed, 9th line and/or
10th line will be ignored. I tried to test, but it seems not working.
It accepts to execute 9th line and 10th line while #undef is
executed. I don't know why.
Do I have to accept the fact that I can't use #define and #undef
inside most functions before it calls function with 10 lines? Then, I
am advised to create 3 duplicated functions -- 8 lines, 9 lines, and
10 lines. Most functions will have pointer to function that can
choose to point one of three duplicated functions. The problem is
that I want 3 functions to be forceinlined for best performance
because pointer to function does not allow. If I try, I will get
error message saying, inline or forceinlined must be removed before it
is compiled.
Please advise what I have to do other option.
checked MS Visual C++ 6.0 that it can only limit 8 parameters, but
most C/C++ Compiler can limit maximum 256 parameters. Can you please
verify for me?
Usually, I write function that is about 100 lines. I would need
20 parameters which they are all reference to global variable inside
struct. For best optimization, it does not require to create stack
frame because variables are always global inside struct. It is
possible that stack frame is never created because local variables are
never defined.
I like pointer to function into array that it looks like CALL
Table, but I prefer to use switch cases that it looks like JMP Table
because all functions under pointer list can't be inlined or
forceinlined, but only sub-functions can be inlined or forceinlined
inside pointer to function list.
Are you sure that pointer to function list can only limit to 1,023
while switch cases can limit to 300 or 1,023 for best optimization?
I have another problem with #define, #undef, and #ifdef directive
inside functions. I have three duplicated functions with 10 lines.
First function has 8 lines, Second function has 9 lines. Third
function has 10 lines. I prefer to use only one function so #ifdef
name and #endif will be placed on line 9 and line 10.
Most functions can have #define and #undef before it starts to
call function with 10 lines. If #undef is executed, 9th line and/or
10th line will be ignored. I tried to test, but it seems not working.
It accepts to execute 9th line and 10th line while #undef is
executed. I don't know why.
Do I have to accept the fact that I can't use #define and #undef
inside most functions before it calls function with 10 lines? Then, I
am advised to create 3 duplicated functions -- 8 lines, 9 lines, and
10 lines. Most functions will have pointer to function that can
choose to point one of three duplicated functions. The problem is
that I want 3 functions to be forceinlined for best performance
because pointer to function does not allow. If I try, I will get
error message saying, inline or forceinlined must be removed before it
is compiled.
Please advise what I have to do other option.