Can I deprecate extern declaration ?

C

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
 
I

Ian Collins

CoL said:
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.
 
R

Richard Tobin

This is causing conflict to the std. Linux header file "errno.h" which
declares erno with some defines throwing exception.
[/QUOTE]
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
 
C

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

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[/QUOTE]
 
R

Richard Tobin

CoL said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top