473,394 Members | 2,160 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,394 software developers and data experts.

extern methods

In standard C, what is the effect of declaring a method extern. In
what cases should I use this? Programs that I've compiled with more
than one source files and multiple headers still seem to work even
when a method in one file calls a method in another, even though I've
yet to declare any method extern. Why?
Nov 14 '05 #1
2 4266
Blue Ocean wrote:
In standard C, what is the effect of declaring a method extern. In
what cases should I use this? Programs that I've compiled with more
than one source files and multiple headers still seem to work even
when a method in one file calls a method in another, even though I've
yet to declare any method extern. Why?


There are no methods in C; they're *functions*.

Functions have external linkage by default in C, making the keyword
redundant.

HTH,
--ag

--
Artie Gold -- Austin, Texas

"What they accuse you of -- is what they have planned."
Nov 14 '05 #2

"Blue Ocean" <bl*********@hotmail.com> a écrit dans le message de
news:33**************************@posting.google.c om...
In standard C, what is the effect of declaring a method extern. In
what cases should I use this? Programs that I've compiled with more
than one source files and multiple headers still seem to work even
when a method in one file calls a method in another, even though I've
yet to declare any method extern. Why?


Functions are extern by default. "Methods" exist (maybe) in C++
but not in C. In C "methods" are not associated to a data packet
and called just "Functions".

As you may have noticed, in C functions do not receive an
implicit object pointer (the "this" argument).

So they aren't methods. They are by default extern, i.e. visible
in other modules. If you do not want them to be visible
you define them as static, like this

static int myFn(int someArg)
{}

This means "myFn" will not be visible outside the current unit.

Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: cppaddict | last post by:
In JNI header files generated by javah, what is going on with the 'extern "C"' which is inserted around the native method when "cplusplus" is defined. I would think you would only need extern...
1
by: terrencel | last post by:
I was told to look at some old C code that was ported to C++. One of the file is like: ========================================= CPPClass* someCPPVar = NULL; extern "C" {
5
by: Jacek Dziedzic | last post by:
Hello! In my program I have a matrix class that can be simplified to class Matrix { public: // ... plenty of methods void diagonalize_via_LAPACK(); private:
10
by: Mark A. Gibbs | last post by:
I have a question about mixing C and C++. In a C++ translation unit, I want to define a function with internal linkage and C calling convention. Here's a sample of what I want to do: //...
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...
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 ;
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: chetanamale | last post by:
Hello : Can anyone please elaborate in detailed use of extern in c/c++.The articles i read say " its used for those methods/functions defined somewhere else", e.g.extern 'function name',...
5
by: Anonymous | last post by:
I have a class that needs to be accesed by a C API. I need to expose some private methods to the C API : #ifdef __cplusplus extern "C" #endif void peek(Object_Handle handle); void...
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:
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.