Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Function Prototype Identifying Issue ??(Function Prototype identification)
Function Prototype Identifying Issue ?? [message #1385922] Thu, 12 June 2014 09:37 Go to next message
Deepak P is currently offline Deepak PFriend
Messages: 32
Registered: January 2012
Member
Hello All,

Recently when working with CDT found out an issue when identifying the Function Prototype (Function Declaration).

The scenario goes as mentioned below,

Consider a c file which contains a function prototype as mentioned below

int sum(int,int); // argument variable names are missing

When this is parsed by CDT, the Signature of the function is given as "sum()" instead of "sum(int, int)"

Now instead if the same is declared as below

int sum(int a, int b); // Giving variable names for the arguments

CDT identifies the signature correctly. ie., we get sum (int, int)

So is there a way to identify the arguments of the function prototype even when the argument variables doesnt contain name ??

Regards,
Deepak P
Re: Function Prototype Identifying Issue ?? [message #1386088 is a reply to message #1385922] Fri, 13 June 2014 11:33 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Quote:
Consider a c file which contains a function prototype as mentioned below

int sum(int,int); // argument variable names are missing

Is this valid C code? I think this is only possible in C++. But I could be wrong, it is already Friday..


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Function Prototype Identifying Issue ?? [message #1386291 is a reply to message #1386088] Mon, 16 June 2014 11:55 Go to previous messageGo to next message
Deepak P is currently offline Deepak PFriend
Messages: 32
Registered: January 2012
Member
The above syntax is allowed.
Reference for the same is given below.

Ref : http://www.eskimo.com/~scs/cclass/notes/sx5b.html

Also please correct me, if it the declaration is not allowed.

[Updated on: Mon, 16 June 2014 11:56]

Report message to a moderator

Re: Function Prototype Identifying Issue ?? [message #1386375 is a reply to message #1386291] Tue, 17 June 2014 08:21 Go to previous message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
You are right. This is legal C code.

I just tried with a simple program and Eclipse Kepler (CDT 8.3).
Header with prototype declaration
int sum(int,int);

no implementation in .c file

When I type "sum" in my main.c and then hit Ctrl-Space Eclipse suggests "sum(int,int): int".

When I have an implementation in a .c file then Eclipse suggests "sum(int a,int b): int".

It also works when I put the empty declaration in the .c file. See attached screen shot



Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Previous Topic:CDT not working after update
Next Topic:source code
Goto Forum:
  


Current Time: Fri Apr 26 16:28:59 GMT 2024

Powered by FUDForum. Page generated in 0.04271 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top