[Solved] Prototype already declared

Just starting out? Need help? Post your questions and find answers here.
BarryG
Addict
Addict
Posts: 3324
Joined: Thu Apr 18, 2019 8:17 am

[Solved] Prototype already declared

Post by BarryG »

[Edit] Solved. That line was in an IncludeFile, which I accidentally included twice with a small source change today. :oops: Hence why searching my sources didn't show any duplicates.

I hope this info helps someone else in future, because searching these forums for "Prototype already declared" had no obvious matches for this issue.

And now, my original post for posterity:

I'm getting a "Prototype already declared" error for my app today, seemingly out of the blue. For this line:

Code: Select all

Prototype DwmGetWindowAttribute_(hWnd,dwAttribute.l,*pvAttribute,cbAttribute.l)
But when I search all my source files for "DwmGetWindowAttribute", that line is the ONLY single place it's found. So what's happening?

If I comment out the line, then my app doesn't compile with a different error ("Structure not found: DwmGetWindowAttribute_.")

But my concern is why the Prototype line is now suddenly throwing an error, when I've been using it without problems for months?
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [Solved] Prototype already declared

Post by Little John »

BarryG wrote:[Edit] Solved. That line was in an IncludeFile, which I accidentally included twice with a small source change today. :oops:
I never use IncludeFile, but only XIncludeFile. I wonder whether there is need for the IncludeFile statement at all. Perhaps it should be declared deprecated.
BarryG
Addict
Addict
Posts: 3324
Joined: Thu Apr 18, 2019 8:17 am

Re: [Solved] Prototype already declared

Post by BarryG »

I was thinking about that too, LJ. But then I realised sometimes IncludeFiles are not procedures, but just little code snippets that you may want to include at that point, similar to a macro insertion. So yeah, both types are needed.
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [Solved] Prototype already declared

Post by Little John »

The files that I personally use with XIncludeFile only contain definitions (constants, structures, prototypes), as well as macros and procedures (mostly inside of modules).
However, I see now. Generally speaking, you are right, of course.
User avatar
skywalk
Addict
Addict
Posts: 3999
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [Solved] Prototype already declared

Post by skywalk »

I struggle to justify naked IncludeFile's. This and EnableExplicit OFF are recipes for sour code.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Tenaja
Addict
Addict
Posts: 1949
Joined: Tue Nov 09, 2010 10:15 pm

Re: [Solved] Prototype already declared

Post by Tenaja »

skywalk wrote:I struggle to justify naked IncludeFile's. This and EnableExplicit OFF are recipes for sour code.
+1
Post Reply