473,657 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function Prototype - different argument names

Hi,

I notice a function prototype being declared as following:

FileStream.h
=========
extern void openFile(char *__ident, int __option);

But, in the function declaration part shown as following:
FileStream.c
=========
void openFile(char *ident, int option)
{
...
}

Why is that the "__" prefix for "ident" and "option" required?

Rgds,

Mike

Jul 18 '06 #1
3 4517

cybernerdsx2 wrote:
Hi,

I notice a function prototype being declared as following:

FileStream.h
=========
extern void openFile(char *__ident, int __option);

But, in the function declaration part shown as following:
FileStream.c
=========
void openFile(char *ident, int option)
{
...
}

Why is that the "__" prefix for "ident" and "option" required?
parameter names in the function prototype are not mandatory and it can
have different names. i.e., it could be
extern void openFile(char *, int );
or
extern void openFile(char *idnt, int opt);

the usage of prefix '__' in variable names is not recommended as it is
inteded to use by the compiler for internal purpose.

--Mohan
Rgds,

Mike
Jul 18 '06 #2

Mohan wrote:
cybernerdsx2 wrote:
Hi,

I notice a function prototype being declared as following:

FileStream.h
=========
extern void openFile(char *__ident, int __option);

But, in the function declaration part shown as following:
FileStream.c
=========
void openFile(char *ident, int option)
{
...
}

Why is that the "__" prefix for "ident" and "option" required?
parameter names in the function prototype are not mandatory and it can
have different names. i.e., it could be
extern void openFile(char *, int );
or
extern void openFile(char *idnt, int opt);

the usage of prefix '__' in variable names is not recommended as it is
inteded to use by the compiler for internal purpose.
Anyway in the prototype the paramenter names are ignored by the
compiler, it is just required to be a valid identifier.
Rgds,

Mike
Jul 18 '06 #3
In article <11************ *********@m79g2 000cwm.googlegr oups.com>
cybernerdsx2 <fo*********@gm ail.comwrote:
>I notice a function prototype being declared as following:

FileStream.h
=========
extern void openFile(char *__ident, int __option);

But, in the function declaration part shown as following:
FileStream.c
=========
void openFile(char *ident, int option)
{
...
}

Why is that the "__" prefix for "ident" and "option" required?
They are not only not required, they are also a *bad* idea, with
one exception.

As far as the C standards are concerned, there are only two kinds
of programmers in the world: ones like me, who write the compilers
for you -- we are called "implemento rs" -- and ones like you, who
use the compilers we write.

Suppose I, as an implementor, am working on the file that I will
provide as <string.h>. In this file, I write:

char *strcpy(char *restrict dst, const char *restrict src);

Now you, as the user of my <string.h>, do this:

/* this is my module that does some funny stuff with times */
#define dst 1 /* compile in support for Daylight Saving Time */

#include <string.h/* I need some functions from here */

You defined "dst" as 1, and then you included my (implementor's)
<string.h>, which -- in my implementation at least -- is just an
ordinary file with ordinary C rules applied. So the line I wrote
now reads, to the compiler, as:

char *strcpy(char *restrict 1, const char *restrict src);

and you get a "syntax error".

This is my fault: as an implementor, I *must* allow you to "#define
dst" however you like. So I *cannot* use that name.

If I want to use names in my <string.hprotot ypes, what can I do?

The answer is: I can use names that, according to the C standands,
*you* must *not* use. Those names include any names that start
with double underscore, or underscore followed by an uppercase
letter. So *I* can use:

char *strcpy(char *restrict __dst, const char *restrict _SRC);

and thus be sure that I did not use any of "your" names. These
names are "my" names: names reserved to me.

If you use any of my names, the problem is yours, not mine. You
stick to your names, and I stick to mine, and everything will be
just fine.

(The other alternative here is that I can just write the prototypes
with no names at all. But at some point, I have to write various
internal functions, e.g., to implement parts of fopen(), fclose(),
fflush(), and so on; I will need names for those functions, and I
will need to make sure that my names do not conflict with your names.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Jul 18 '06 #4

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

Similar topics

5
34359
by: kazack | last post by:
I am a little confused with code I am looking at. My c++ book does not go into passing a structure to a function so I pulled out a c book which does. and I do not understand the prototype verses the actual function call. I will post the code below of the structure, the prototype and and function call and if someone can explain this I would be very appreciative: struct data { float amount; string fname;
3
14928
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
6
15207
by: marktm | last post by:
Hi- I am trying to use setInterval to call a method within an object and have not had any luck. I get "Object doesn't support this property or method" when I execute the following code. What I am doing wrong? Your help will be much appreciated. Thanks
13
4339
by: Roy Hills | last post by:
I've seen two different function prototype formats used for ANSI C, and I'm unsure as to which is the correct or preferred one. 1st Format (this is what I use) type function(type, type, type); e.g. "int multiply(int, int);" 2nd Format (I've seen this used in other people's code)
28
4307
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
28
6028
by: ravi | last post by:
Hello everybody, I am writing a small application which does some work before the user main function starts execution. I am trying to #define the main function. But the problem is that,
13
1822
by: Jim Mackellan | last post by:
In my opinion, C not mungling its function names imposes unnecessary complexity on C++, requiring extern 'C' { ... } everywhere in headers. I believe that in the next version of the ISO standard, C should move to mungling its function names consistently with C++ to improve interoperability. Acutally this should have happened long ago. Regards, Jim
9
2369
by: Yannick | last post by:
Hi everyone - I am not quite sure to understand what is really going on when a function defined in one translation unit calls a function defined in a different translation unit without knowing its prototype. Let's say for instance : foo.c #include <stdio.h>
18
1837
by: Aaron Gray | last post by:
I know this has probably been argued to death, but I am going to raise it fresh again, and basically lets have an unofficial 'isArray()' contest that we can hopefully put it to rest as best as we can. I have found things that work perfectly well as long as you don't try them on MSIE, ie adding Object and Array prototype isArray functions, thus :- Object.prototype.isArray = function() { return false } Array.prototype.isArray =...
0
8403
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8737
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.