By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

Can I deprecate extern declaration ?

P: n/a
CoL
Hi All,
I am working on a code that consumes third party libraries. My problem
is
extern int errno;
is declared in one of those third party headers.
This is causing conflict to the std. Linux header file "errno.h" which
declares erno with some defines throwing exception.

Is there any way I could deprecate the third party declation without
modifiy that header.
Thanks in advance.

Regards
COL

Nov 7 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
CoL wrote:
Hi All,
I am working on a code that consumes third party libraries. My problem
is
extern int errno;
is declared in one of those third party headers.
This is causing conflict to the std. Linux header file "errno.h" which
declares erno with some defines throwing exception.
Are you sure? You have written erno (single r) above. I can't imagine
any OS using exceptions (which don't exist in C) in a system header.
Is there any way I could deprecate the third party declation without
modifiy that header.
Not unless it is defined as a macro, where you can #undef it, but you
can't change an extern declaration.

--
Ian Collins.
Nov 7 '06 #2

P: n/a
In article <4r************@mid.individual.net>,
Ian Collins <ia******@hotmail.comwrote:
>This is causing conflict to the std. Linux header file "errno.h" which
declares erno with some defines throwing exception.
>Are you sure? You have written erno (single r) above. I can't imagine
any OS using exceptions (which don't exist in C) in a system header.
More likely it defines errno in some way (such as a function call)
to refer to a per-thread copy.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 7 '06 #3

P: n/a
CoL
Thats correct Richard and Ian....its exactly that only. Thats what
defining a macro in the header file should work but thats exactly we
dont want to modify the
third party header.. :(

code snippet in errno.h-
# ifndef __ASSEMBLER__
/* Function to get address of global `errno' variable. */
extern int *__errno_location (void) __THROW __attribute__
((__const__));

# if !defined _LIBC || defined _LIBC_REENTRANT
/* When using threads, errno is a per-thread value. */
# define errno (*__errno_location ())
# endif
# endif /* !__ASSEMBLER__ */
#endif /* _ERRNO_H */

Thanks for your reply.
Regards,
COL

Richard Tobin wrote:
In article <4r************@mid.individual.net>,
Ian Collins <ia******@hotmail.comwrote:
This is causing conflict to the std. Linux header file "errno.h" which
declares erno with some defines throwing exception.
Are you sure? You have written erno (single r) above. I can't imagine
any OS using exceptions (which don't exist in C) in a system header.

More likely it defines errno in some way (such as a function call)
to refer to a per-thread copy.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 7 '06 #4

P: n/a
In article <11*********************@m7g2000cwm.googlegroups.c om>,
CoL <ap***********@gmail.comwrote:
>Thats correct Richard and Ian....its exactly that only. Thats what
defining a macro in the header file should work but thats exactly we
dont want to modify the
third party header.. :(
Their code's wrong, so it *ought* to be modified.

If the header doesn't (directly or indirectly) include <errno.h>
itself, and you can modify the file that includes the header, you
could put

#define errno some_junk

before the #include and

#undef errno

after it. That way the header would just declare some_junk instead.

Alternatively perhaps you could avoid including their header
altogether and declare the necessary things from it yourself?
Obviously this will cause problems if they modify it later.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.