473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Can I deprecate extern declaration ?

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
4 1766
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: tweak | last post by:
What's the best way to use extern when using multiplefiles that is easiest to maintain? Is it best to declare: extern int a; in a header file and include the header file in all files except...
12
by: G Patel | last post by:
I've seen some code with extern modifiers in front of variables declared inside blocks. Are these purely definitions (no definition) or are they definitions with static duration but external...
19
by: ccwork | last post by:
Hi all, I am reading "C: A Reference Manual" 4th ed and I get lost for the "extern". It says that global object without specifying the storage-class specifier will have "extern" as the default...
29
by: DevarajA | last post by:
Can anyone explain me what extern is used for? I thought it was used to declare variables definited in other files, but i can do that also without extern. /*file a.c*/ int a=5; int main() {...
5
by: siliconwafer | last post by:
Hi all, I wanted to know that is use of extern keyword mandatory in case of global variables and functions used in other source files? i.e consider a following piece of code from MSDN explaining...
17
by: Tapeesh | last post by:
I would like to know what is the expected behaviour of C compilers when an extern decleration is intialized. When the following code is compiled using gcc //File extern.c int arr ; int a ;
7
by: MikeF | last post by:
Group, I have a variable declared in 'main.c' as: const unsigned int x = 1; I have another module which uses this same variable, I've tried to declare as:
5
by: Christian Christmann | last post by:
Hi, I've tree questions on the storage class specifier "extern": 1) Code example: int main( void ) { int b = -2; // my line 3 if ( a ) {
5
by: jchludzinski | last post by:
I have 3 files (see below: a.h, w.c, ww.c). I would like to use a single x (declared somewhere) which would global to both compilation units: w.c & ww.c. No matter where I place the "extern"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.