Should Declare use be avoided as much as possible?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Should Declare use be avoided as much as possible?

Post by Tenaja »

We are on the same page, then.

Don't miss the edit to my last post.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Should Declare use be avoided as much as possible?

Post by Shield »

Tenaja wrote:Don't miss the edit to my last post.
Yep, +1 on that one. :)
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
idle
Always Here
Always Here
Posts: 5839
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Should Declare use be avoided as much as possible?

Post by idle »

I think it's good practice to use declares from a documentation point of view, they tell you at a glance whats
in the source and there's absolutely no penalty from using them since they're not compiled into the executable.
They're simply required in some cases when there's a forward reference since the compiler only does a single pass
declare simply adds the function to the compilers symbol table and functions prototypes so it can do type checks
and what not.
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
Blood
Enthusiast
Enthusiast
Posts: 161
Joined: Tue Dec 08, 2009 8:34 pm
Location: United Kingdom

Re: Should Declare use be avoided as much as possible?

Post by Blood »

idle wrote:I think it's good practice to use declares from a documentation point of view, they tell you at a glance whats
in the source
The IDE does that.
C provides the infinitely-abusable goto statement, and labels to branch to. Formally, the goto is never necessary, and in practice it is almost always easy to write code without it. We have not used goto in this book. -- K&R (2nd Ed.) : Page 65
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Should Declare use be avoided as much as possible?

Post by Tenaja »

Notepad++ doesn't... :mrgreen:
User avatar
Blood
Enthusiast
Enthusiast
Posts: 161
Joined: Tue Dec 08, 2009 8:34 pm
Location: United Kingdom

Re: Should Declare use be avoided as much as possible?

Post by Blood »

Tenaja wrote:Notepad++ doesn't... :mrgreen:
Write a plugin. There are a few function list plugins available for Notepad++ for ideas.
C provides the infinitely-abusable goto statement, and labels to branch to. Formally, the goto is never necessary, and in practice it is almost always easy to write code without it. We have not used goto in this book. -- K&R (2nd Ed.) : Page 65
User avatar
idle
Always Here
Always Here
Posts: 5839
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Should Declare use be avoided as much as possible?

Post by idle »

Blood wrote:
idle wrote:I think it's good practice to use declares from a documentation point of view, they tell you at a glance whats
in the source
The IDE does that.
sure it shows you the functions but not the parameters,though if your implementing a class you generally need to declare the functions
its pretty much personal preference at the end of the day
Windows 11, Manjaro, Raspberry Pi OS
Image
Post Reply