Message-Id: <199906011820.SAA19762@out4.ibm.net> From: "Mark E." To: djgpp-workers AT delorie DOT com Date: Tue, 1 Jun 1999 14:22:04 -0400 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: enhancements to fcntl.c References: <199905311824 DOT SAA72470 AT out2 DOT ibm DOT net> In-reply-to: X-mailer: Pegasus Mail for Win32 (v3.11) Reply-To: djgpp-workers AT delorie DOT com Eli, Thanks for running the tests. I've created a macro to detect when the optional arguments are present. But I don't know how portable across compiler versions it is: #define __dj_HAVE_OPTIONAL_ARGS(x) \ ((int *)__builtin_frame_address(1) - (int *)__builtin_next_arg(x) - 2) where x is the last non-optional argument. An example: void func_with_opt_args(int x, ...) { if (__dj_HAVE_OPTIONAL_ARGS(x)) printf("Have optional args.\n"); else printf("Do not have optional args.\n"); } int main() { func_with_optional_args(1, 2); func_with_optional_args(1); return 0; } If it is portable between different compiler versions, the macro could be used in open and fcntl to avoid reading arguments from the stack that aren't there. --- Mark Elbrecht, snowball3 AT bigfoot DOT com http://snowball.frogspace.net/