Sponsored Content
Full Discussion: extern for functions
Top Forums Programming extern for functions Post 302119120 by porter on Monday 28th of May 2007 05:34:57 AM
Old 05-28-2007
extern is not needed for functions, but is needed when refering to external data to avoid duplicate declaration of statics which can be very hard to track down.

Prototypes however are a good idea and required even by K&R if the function does not return an int.

It is good practice and warms you up for when you start mixing C with C++.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regarding functions

Hi, I have a function or script like this. show() { echo "Hi" } | tee -a log show This creates a logfile and prints Hi in it. Now when I try to do the same for sql like this: show() { sqlplus -s scott/tiger<<! select * from details; ! } | tee -a log show Then it gives me a... (2 Replies)
Discussion started by: sendhilmani
2 Replies

2. Programming

Extern variable.

file1.c int a1; int main() { a1 = 2; printf("\na1 = %d\n", a1); next(); printf("\na1 = %d\n", a1); next1(); printf("\na1 = %d\n", a1); } file2.c #include <stdio.h> int b1 = 0; void next(void) (1 Reply)
Discussion started by: Tanvirk
1 Replies

3. Linux

Problem mounting extern hd (fedora 9)

Hi there, I'm having a bit of a strange problem which I would appreciate some help with. The Problem: I have two external hard drives, but I'm borrowing one off my parents to copy data too (one of mine, which is identical to theirs - WD MyBook 300g - is on its way out). Fedora 9 recognizes... (3 Replies)
Discussion started by: lasthidingplace
3 Replies

4. UNIX for Dummies Questions & Answers

fetchmail and forward to an extern address

Hi, I'm searching for an solution for the following problem. I want fetch some mails via pop3 from a@a.com with fetchmail. That works perfectly. Now any incoming mail should forwarded to b@b.com via smtp obv. But I don't know how to configure that. All online tutorials describe forwarding to... (0 Replies)
Discussion started by: mcW
0 Replies

5. Programming

segmentation fault for extern

Why this is happening when both of them compiled together and run? I am getting segmentation fault SIGSEGV. File1.c: int arr; File2.c: extern int *arr; int main() { arr = 100; } (3 Replies)
Discussion started by: royalibrahim
3 Replies

6. Shell Programming and Scripting

i think i need functions ?

Hi, im making a little script but need some help Code i have so far is read -p 'Bot Nickname:' ecnick read -p 'Bot Username:' ecusername read -p 'Bot Realname:' ecrealname read -p 'Your Email:' ecemail echo '' echo Your bots nickname is set to $ecnick echo Your bots username is set to... (2 Replies)
Discussion started by: Gemster
2 Replies

7. Programming

Functions

Hi All, Can any one help me. I am calling in a function2 with string as parameter from function1, the function1 gives 3 values. how i get the 3 values from funciton2 to function1. i have to give a return or something. thanks in advance. (2 Replies)
Discussion started by: uday.sena.m
2 Replies

8. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

9. Programming

C header file and extern

In the header file data.h i got: const char ack_msg = "ack: received your msg\n"; In the code file server.c i got: extern const char ack_msg; And else it is only used in a function call: user$ grep ack_msg *c *h server.c:extern const char ack_msg; server.c: n = write(clientsfd,... (5 Replies)
Discussion started by: tornow
5 Replies

10. Programming

Extern keyward on function in C

I saw a header (.h) file with mixture of "regular" function declarations and other extern function declarations. As I was told all function declarations are implicitly external and the extern on functions declarations is superfluous. Here my focus is on function declaration, not variable yet. int... (2 Replies)
Discussion started by: yifangt
2 Replies
nm(1)							      General Commands Manual							     nm(1)

Name
       nm - name list dump of RISC object files

Syntax
       nm [-adefghnopruvxABTV] [ file1 ... filen ]

Description
       The  nm	command  prints listings formats for the symbol and external sections of the symbol table.  A file can be an object or an archive.
       If you do not specify a file, this command assumes a.out.

Options
       The -A and -B options specify AT&T System V style output or Berkeley (4.3  BSD) style output, respectively.  The default is  Berkeley  (4.3
       BSD).  Some options can change the version-specific defaults. These options change the meaning of overloaded flags after -A or -B is speci-
       fied.

       A normal Berkeley system produces the address or value field followed by a letter showing what section the symbol or external is in and the
       name of the symbol or external.

       These section letters describe the information that nm generates:

       N    nil storage class, compiler internal usage

       T    external text

       t    local text

       D    external initialized data

       d    local initialized data

       B    external zeroed data

       b    local zeroed data

       A    external absolute

       a    local absolute

       U    external undefined

       G    external small initialized data

       g    local small initialized data

       S    external small zeroed data

       s    local small zeroed data

       R    external read only

       r    local read only

       C    common

       E    small common

       V    external small undefined

       The standard  System V format and the -a specified Berkeley format provide an expanded listing with these columns:

       Name    the symbol or external name

       Value   the value field for the symbol or external, usually an address or interesting debugging information

       Class   the symbol type

       Type    the symbol's language declaration

       Size    unused

       Index   the symbol's index field

       Section the  symbol's  storage  class  Every  effort  was made to map the field's functionality into System V nomenclature.  The nm command
	       accepts these options:

       -a   prints debugging information, effectively turning Berkeley into System V format

       -b   prints the value field in octal

       -d   prints the value field in decimal (the System V default)

       -e   prints external and statics only

       -f   produces full output--nm still accepts this old option, but ignores it

       -h   does not print headers

       -n   for System V, sorts external symbols by name (default for Berkeley), and for Berkeley, sorts all symbols by value

       -o   for System V, prints the value field in octal, and for Berkeley prepends the filename to each symbol--good for grepping through nm	of
	    libraries

       -p   prints symbols as they are found in the file (the System V default)

       -r   reverses the sense of a value or name sort

       -u   prints only undefined symbols

       -v   sorts external symbols by value

       -x   prints value field in hexadecimal (Berkeley default)

       -T   truncates long names, inserting an asterisk (*) as the last printed character

       -V   prints version information on stderr

								       RISC								     nm(1)
All times are GMT -4. The time now is 05:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy