Linux System C headers puzzling


 
Thread Tools Search this Thread
Top Forums Programming Linux System C headers puzzling
# 1  
Old 01-27-2010
Java Linux System C headers puzzling

I am new to Linux system programming, and I found the sophisiticated definition of some library function differ a lot with what I learnt in classes.

Here is the question:
what does the suffix of function `chmod' in sys/stat.h mean. The funtion claimation is like following:
Code:
    extern int chmod (__const char *__file, __mode_t __mode)
     __THROW __nonnull ((1));

According to my broken programming knowledge, suffix like "__THROW __nonnull ((1))" appear only in the C++, and they are generally used to handle the throwing of exceptions inside the functions.

I am glad anybody who is willing to share his/her idea. Thanks a lot.

Last edited by pludi; 01-27-2010 at 02:59 AM.. Reason: code tags, please...
# 2  
Old 01-27-2010
Hi,

those functions qualifiers are simply compiler directives to tell gcc: this function does not throw any exception, and the first pointer must be non NULL. With this information, the compiler can better optimize the code around the call to chmod(), especially if you're calling chmod() from a C++ code.

These macro can be found in /usr/include/sys/cdefs.h by the way.

HTH,
Loïc.
# 3  
Old 01-27-2010
gcc has lots of nonstandard extensions like that. Some assist the programmer by providing warnings or errors for things the compiler wouldn't otherwise be able to catch. I've had gcc warn me that I called printf with an incorrect number of arguments, an error message of quite surprising intelligence.
# 4  
Old 01-27-2010
But I think not only the gcc does, because the busybox source package can also be compiled using the windows vs2005 (which has the support for GNU makefile), so may be the ANSI C has already added the support for more functionality (including the exceptional handling mechanism). (I guessSmilie)
# 5  
Old 01-27-2010
C++ exceptions remain C++.

Being compiled under Visual Studio 2005 would mean using the Visual Studio headers and not the glibc ones, would it not?
# 6  
Old 01-27-2010
My god, I forgot that all the C codes under vs2005 are compiled using the same compiler shared by the C++'s. Thanks for reminding.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Sys headers - running Linux C code on windows

Hi All, I wanted to run a small socket application written in C on windows. The code was written for GNU/linux..the compiler on windows CodeBlocks complains about the sys headers. is there an equivalent for windows ? (4 Replies)
Discussion started by: coolatt
4 Replies

2. UNIX for Dummies Questions & Answers

Append file name to fasta file headers in Linux

How do we append the file name to fasta file headers in multiple fasta-files in Linux? (10 Replies)
Discussion started by: Mauve
10 Replies

3. UNIX for Dummies Questions & Answers

Puzzling permission issue

I have a file, the long listing output by 'ls -l' is -rw-r--r-- 1 usera agroup 1246 Jul 7 14:44 temp.R The file is under a Solaris ZFS file system. As a different user (userb), I did cp temp.R /tmp ls -l /tmp/temp.R -rw-r--r-- 1 userb agroup 1246 Nov 16 14:45 /tmp/temp.R ... (14 Replies)
Discussion started by: nugulus
14 Replies

4. Shell Programming and Scripting

Merging of files with different headers to make combined headers file

Hi , I have a typical situation. I have 4 files and with different headers (number of headers is varible ). I need to make such a merged file which will have headers combined from all files (comman coluns should appear once only). For example - File 1 H1|H2|H3|H4 11|12|13|14 21|22|23|23... (1 Reply)
Discussion started by: marut_ashu
1 Replies

5. IP Networking

Puzzling Traceroute output

This is the output that I get every so often when trying to do a traceroute to the web server whenever it's inaccessible: traceroute to 64.40.98.181 (64.40.98.181), 30 hops max, 40 byte packets 1 207.97.207.194 (207.97.207.194) 2.625 ms 2.840 ms 2.968 ms 2 core1-5.iad1.rackspace.com... (6 Replies)
Discussion started by: gaspol
6 Replies

6. Shell Programming and Scripting

Syntax error, puzzling

I am just learning over here unix scripting and the OS in general. I wrote this script (with some great help from you guys here) when I test at my desktop with cygwin it works fine, but when I take it to work and try it on the Solaris 2 system there I get an error on line 4 syntax error... (4 Replies)
Discussion started by: Fred Goldman
4 Replies

7. Shell Programming and Scripting

Remove text between headers while leaving headers intact

Hi, I'm trying to strip all lines between two headers in a file: ### BEGIN ### Text to remove, contains all kinds of characters ... Antispyware-Downloadserver.com (Germany)=http://www.antispyware-downloadserver.c om/updates/ Antispyware-Downloadserver.com #2... (3 Replies)
Discussion started by: Trones
3 Replies

8. Shell Programming and Scripting

puzzling regexp

hey guys, i'm having some problems with my understanding of this whole regexp thing. I'm just exploring here really by trying to do various match & filter & print stuff on the console. I figured i want to get the IP of an interface. So my idea here was that first i filter to extract only... (4 Replies)
Discussion started by: jad
4 Replies

9. Shell Programming and Scripting

AWk is still puzzling me...

Hi all. Here's what i want to do: my_first_file #!/usr/bin/ksh # BLA BLA BLA BLA printf "this is my first file \n" echo " I understand this far" printf "the day's over \n" echo "great" my_second_file #!/usr/bin/ksh # BLA BLA BLA BLA printf "this is my first file \n" AN_INSERTED_LINE... (2 Replies)
Discussion started by: penguin-friend
2 Replies

10. UNIX for Dummies Questions & Answers

System Headers Path?

Is there an environment variable or other mechanism whereby I can get the system headers path? Preferrably I would like to be able to gather this information independant of the flavor of Unix. Thanks, Scott. (1 Reply)
Discussion started by: scottr
1 Replies
Login or Register to Ask a Question