Board index » Visual Studio » Why Compiler Const Error when no Compiler Const exists

Why Compiler Const Error when no Compiler Const exists

Visual Studio272
I get an error for a duplicate compiler const. I have no compiler const in

my project. Any idea why this might happen?

--

Regards,

Jamie


-
 

Re:Why Compiler Const Error when no Compiler Const exists

"thejamie" <thejamie@discussions.microsoft.com>wrote in message

Quote
I get an error for a duplicate compiler const. I have no compiler

const in my project. Any idea why this might happen?



What version of VB? Can you post the exact error message?



--

Reply to the group so all can participate

VB.Net: "Fool me once..."



-

Re:Why Compiler Const Error when no Compiler Const exists

Bob,



Version VB6 SP6.



Error is straightforward:

Modal header is "Microsoft Visual Basic"



Message is "DUPLICATE DEFINITION"



the message provides an OK and HELP option.



I click OK and tried to open the program again - got the same message. This

happened after a compile.



Jamie



"Bob Butler" wrote:



Quote
"thejamie" <thejamie@discussions.microsoft.com>wrote in message

news:3C57D5F6-7303-4ACB-B190-1FF8D23922C8@microsoft.com

>I get an error for a duplicate compiler const. I have no compiler

>const in my project. Any idea why this might happen?



What version of VB? Can you post the exact error message?



--

Reply to the group so all can participate

VB.Net: "Fool me once..."





-

Re:Why Compiler Const Error when no Compiler Const exists



Update:



I tried the following:

Reviewed all public constants - gave them all capital letters and saved.

This did nothing, but I thought it was worth a try.

Second. Checked in entire project and deleted the project from the computer.

Third. Checked entire project out again.

Fourth. Opened project and got same message.

Different - Second time opened project. No explanation. But I am running

again. I wish I could explain this behavior.



Jamie

"Bob Butler" wrote:



Quote
"thejamie" <thejamie@discussions.microsoft.com>wrote in message

news:3C57D5F6-7303-4ACB-B190-1FF8D23922C8@microsoft.com

>I get an error for a duplicate compiler const. I have no compiler

>const in my project. Any idea why this might happen?



What version of VB? Can you post the exact error message?



--

Reply to the group so all can participate

VB.Net: "Fool me once..."





-

Re:Why Compiler Const Error when no Compiler Const exists

"thejamie" <thejamie@discussions.microsoft.com>wrote in message

Quote
Bob,



Version VB6 SP6.



Error is straightforward:

Modal header is "Microsoft Visual Basic"



Message is "DUPLICATE DEFINITION"



the message provides an OK and HELP option.



I click OK and tried to open the program again - got the same

message. This happened after a compile.



I've searched for similar errors and tried a number of variations and can't

duplicate it. Does it highlight a particular line of code? What makes you

say it is a 'compiler const' error? Do you have 'Option Explicit' in all

modules?



--

Reply to the group so all can participate

VB.Net: "Fool me once..."



-

Re:Why Compiler Const Error when no Compiler Const exists

Option Explicit may have been the issue. I found a module that did not have

it listed at the top. That sure seemed simple enough.

Thanks, I hope that was it.



"Bob Butler" wrote:



Quote
"thejamie" <thejamie@discussions.microsoft.com>wrote in message

news:EF318380-9038-4737-8086-072EFE43BCD3@microsoft.com

>Bob,

>

>Version VB6 SP6.

>

>Error is straightforward:

>Modal header is "Microsoft Visual Basic"

>

>Message is "DUPLICATE DEFINITION"

>

>the message provides an OK and HELP option.

>

>I click OK and tried to open the program again - got the same

>message. This happened after a compile.



I've searched for similar errors and tried a number of variations and can't

duplicate it. Does it highlight a particular line of code? What makes you

say it is a 'compiler const' error? Do you have 'Option Explicit' in all

modules?



--

Reply to the group so all can participate

VB.Net: "Fool me once..."





-

Re:Why Compiler Const Error when no Compiler Const exists

"thejamie" <thejamie@discussions.microsoft.com>wrote in message

Quote
Option Explicit may have been the issue. I found a module that did

not have it listed at the top. That sure seemed simple enough.

Thanks, I hope that was it.



That won't fix the error but may help you find it



--

Reply to the group so all can participate

VB.Net: "Fool me once..."



-

Re:Why Compiler Const Error when no Compiler Const exists



"thejamie" <thejamie@discussions.microsoft.com>wrote in message

Quote
Bob,



Version VB6 SP6.



Error is straightforward:

Modal header is "Microsoft Visual Basic"



Message is "DUPLICATE DEFINITION"



the message provides an OK and HELP option.



I click OK and tried to open the program again - got the same message.

This

happened after a compile.





You most likely have 2 procedures of the same name and within the same

scope. Since VB can't determine which one you intended to call, it raises a

duplicate definition error. Search your project for the procedure and limit

the scope of one of the procedures, or if the procedures are actually

identical, eliminate of them.



Mike





-

Re:Why Compiler Const Error when no Compiler Const exists

"MikeD" <nobody@nowhere.edu>wrote in message

<cut>

Quote
You most likely have 2 procedures of the same name and within the same

scope. Since VB can't determine which one you intended to call, it

raises a duplicate definition error. Search your project for the

procedure and limit the scope of one of the procedures, or if the

procedures are actually identical, eliminate of them.



All I can get is "ambiguous name detected"; no matter what I try I can't get

"duplicate definition" for any variable, procedure or module name conflict.

Of course, I'm running VB6 SP5 so maybe SP6 changed the text of one of the

compiler errors.



--

Reply to the group so all can participate

VB.Net: "Fool me once..."



-

Re:Why Compiler Const Error when no Compiler Const exists

I definitely have procedures with similar names, but to the best of my

knowledge they are all private. I'll check it anyhow and get back. I ran

out of time today.



"MikeD" wrote:



Quote


"thejamie" <thejamie@discussions.microsoft.com>wrote in message

news:EF318380-9038-4737-8086-072EFE43BCD3@microsoft.com...

>Bob,

>

>Version VB6 SP6.

>

>Error is straightforward:

>Modal header is "Microsoft Visual Basic"

>

>Message is "DUPLICATE DEFINITION"

>

>the message provides an OK and HELP option.

>

>I click OK and tried to open the program again - got the same message.

This

>happened after a compile.

>



You most likely have 2 procedures of the same name and within the same

scope. Since VB can't determine which one you intended to call, it raises a

duplicate definition error. Search your project for the procedure and limit

the scope of one of the procedures, or if the procedures are actually

identical, eliminate of them.



Mike







-

Re:Why Compiler Const Error when no Compiler Const exists

I can get 'Duplicate Declaration' by having a Function the same name as one of its parameters. Is that close?



Kelly



"thejamie" <thejamie@discussions.microsoft.com>wrote in message news:7C2B60D9-E584-41A6-883B-B3B7CCD04A4A@microsoft.com...

Quote
I definitely have procedures with similar names, but to the best of my

knowledge they are all private. I'll check it anyhow and get back. I ran

out of time today.



"MikeD" wrote:



>

>"thejamie" <thejamie@discussions.microsoft.com>wrote in message

>news:EF318380-9038-4737-8086-072EFE43BCD3@microsoft.com...

>>Bob,

>>

>>Version VB6 SP6.

>>

>>Error is straightforward:

>>Modal header is "Microsoft Visual Basic"

>>

>>Message is "DUPLICATE DEFINITION"

>>

>>the message provides an OK and HELP option.

>>

>>I click OK and tried to open the program again - got the same message.

>This

>>happened after a compile.

>>

>

>You most likely have 2 procedures of the same name and within the same

>scope. Since VB can't determine which one you intended to call, it raises a

>duplicate definition error. Search your project for the procedure and limit

>the scope of one of the procedures, or if the procedures are actually

>identical, eliminate of them.

>

>Mike

>

>

>





-

Re:Why Compiler Const Error when no Compiler Const exists

"Kelly Ethridge" <kelly@kellyethridge.com>wrote in message

Quote
I can get 'Duplicate Declaration' by having a Function the same name

as one of its parameters. Is that close?



closer than I got; I get 'duplicate definition in current scope' though



--

Reply to the group so all can participate

VB.Net: "Fool me once..."



-

Re:Why Compiler Const Error when no Compiler Const exists

On Mon, 27 Dec 2004 10:52:21 -0800, "Bob Butler"

<tiredofit@nospam.com>wrote:

in <#FpS0UE7EHA.1400@TK2MSFTNGP11.phx.gbl>



Quote
All I can get is "ambiguous name detected"; no matter what I try I can't get

"duplicate definition" for any variable, procedure or module name conflict.

Of course, I'm running VB6 SP5 so maybe SP6 changed the text of one of the

compiler errors.



For what it's worth, I get that error more frequently that I'd

like and it seems to be a completely erroneous as well as

transient error that has been remedied in every case by exiting

the IDE and restarting. The only conclusion I've been able to

draw is that my app is getting too large. :-(





---

Stefan Berglund

-

Re:Why Compiler Const Error when no Compiler Const exists

Something that may be helpful is using mztools (www.mztools.com) to identify

code, variables, and / or methods that are no longer used by your

application....



Basically clean up what you no longer require as it may be indirectly

affecting your application.



--

Chris Hanscom - Microsoft MVP (VB)

Veign's Resource Center

www.veign.com/vrc_main.asp">www.veign.com/vrc_main.asp

--



"Stefan Berglund" <keepit@in.thegroups>wrote in message

Quote
On Mon, 27 Dec 2004 10:52:21 -0800, "Bob Butler"

<tiredofit@nospam.com>wrote:

in <#FpS0UE7EHA.1400@TK2MSFTNGP11.phx.gbl>



>All I can get is "ambiguous name detected"; no matter what I try I can't

get

>"duplicate definition" for any variable, procedure or module name

conflict.

>Of course, I'm running VB6 SP5 so maybe SP6 changed the text of one of

the

>compiler errors.



For what it's worth, I get that error more frequently that I'd

like and it seems to be a completely erroneous as well as

transient error that has been remedied in every case by exiting

the IDE and restarting. The only conclusion I've been able to

draw is that my app is getting too large. :-(





---

Stefan Berglund





-

Re:Why Compiler Const Error when no Compiler Const exists

On Mon, 27 Dec 2004 17:45:31 -0500, "Veign"

<NOSPAMinveign@veign.com>wrote:

in <OFO1PZG7EHA.2600@TK2MSFTNGP09.phx.gbl>



Quote
Something that may be helpful is using mztools (www.mztools.com) to identify

code, variables, and / or methods that are no longer used by your

application....



Basically clean up what you no longer require as it may be indirectly

affecting your application.



--

Chris Hanscom - Microsoft MVP (VB)

Veign's Resource Center

www.veign.com/vrc_main.asp">www.veign.com/vrc_main.asp



This is great advice and I've long since followed/applied it, but

the error still shows up randomly after a long editing session.

Exiting the IDE and restarting inevitably remedies the problem.





---

Stefan Berglund

-

Re:Why Compiler Const Error when no Compiler Const exists

As Stefan said, I sometimes get this kind of error erroneously. If I exit

the IDE and reopen VB, it goes away.



--

Brian Schwartz

FishNet Components

www.fishnetcomponents.com">www.fishnetcomponents.com

Building better tools for developers - Be part of it!





"thejamie" <thejamie@discussions.microsoft.com>wrote in message

Quote


Update:



I tried the following:

Reviewed all public constants - gave them all capital letters and saved.

This did nothing, but I thought it was worth a try.

Second. Checked in entire project and deleted the project from the

computer.

Third. Checked entire project out again.

Fourth. Opened project and got same message.

Different - Second time opened project. No explanation. But I am running

again. I wish I could explain this behavior.



Jamie

"Bob Butler" wrote:



>"thejamie" <thejamie@discussions.microsoft.com>wrote in message

>news:3C57D5F6-7303-4ACB-B190-1FF8D23922C8@microsoft.com

>>I get an error for a duplicate compiler const. I have no compiler

>>const in my project. Any idea why this might happen?

>

>What version of VB? Can you post the exact error message?

>

>--

>Reply to the group so all can participate

>VB.Net: "Fool me once..."

>

>





-

Re:Why Compiler Const Error when no Compiler Const exists



"Bob Butler" <tiredofit@nospam.com>wrote in message

Quote
"MikeD" <nobody@nowhere.edu>wrote in message

news:%23dOxGRE7EHA.128@TK2MSFTNGP15.phx.gbl

<cut>

>You most likely have 2 procedures of the same name and within the same

>scope. Since VB can't determine which one you intended to call, it

>raises a duplicate definition error. Search your project for the

>procedure and limit the scope of one of the procedures, or if the

>procedures are actually identical, eliminate of them.



All I can get is "ambiguous name detected"; no matter what I try I can't

get

"duplicate definition" for any variable, procedure or module name

conflict.

Of course, I'm running VB6 SP5 so maybe SP6 changed the text of one of the

compiler errors.



You're right. I was thinking of the ambigous named detected error. I know

I've encountered the duplicate definition error. I can't reproduce it

either though.





-

Re:Why Compiler Const Error when no Compiler Const exists

"Bob Butler" <tiredofit@nospam.com>wrote in message

Quote
"Kelly Ethridge" <kelly@kellyethridge.com>wrote in message

news:eTQvxlE7EHA.4028@TK2MSFTNGP15.phx.gbl

>I can get 'Duplicate Declaration' by having a Function the same name

>as one of its parameters. Is that close?



closer than I got; I get 'duplicate definition in current scope' though







Try this: (from the msdn library)



#Const Mac = 0

#Const Mac = 1







--

Björn Holmgren







-

Re:Why Compiler Const Error when no Compiler Const exists

"Björn Holmgren" <bjohol@hotmail.com>wrote in message

Quote
"Bob Butler" <tiredofit@nospam.com>wrote in message

news:eXZ6Q$E7EHA.3708@TK2MSFTNGP14.phx.gbl...

>"Kelly Ethridge" <kelly@kellyethridge.com>wrote in message

>news:eTQvxlE7EHA.4028@TK2MSFTNGP15.phx.gbl

>>I can get 'Duplicate Declaration' by having a Function the same name

>>as one of its parameters. Is that close?

>

>closer than I got; I get 'duplicate definition in current scope'

>though



Try this: (from the msdn library)



#Const Mac = 0

#Const Mac = 1



I swear I tried that yesterday and got a different error; I tried both Const

and #Const and could not get the 'duplicate definition' error but I do

now...



--

Reply to the group so all can participate

VB.Net: "Fool me once..."



-

Re:Why Compiler Const Error when no Compiler Const exists

Wow - you guys are strange. What Björn has shown here is the help that comes

up when duplicate definition is displayed as the error. Seeing the time and

effort you all put into this, I regret that I didn't provide this information

initially and, for your time and effort, I owe you all a big thanks. See ya

next year!

Jamie



"Björn Holmgren" wrote:



Quote
"Bob Butler" <tiredofit@nospam.com>wrote in message

news:eXZ6Q$E7EHA.3708@TK2MSFTNGP14.phx.gbl...

>"Kelly Ethridge" <kelly@kellyethridge.com>wrote in message

>news:eTQvxlE7EHA.4028@TK2MSFTNGP15.phx.gbl

>>I can get 'Duplicate Declaration' by having a Function the same name

>>as one of its parameters. Is that close?

>

>closer than I got; I get 'duplicate definition in current scope' though

>





Try this: (from the msdn library)



#Const Mac = 0

#Const Mac = 1







--

Björn Holmgren









-

Re:Why Compiler Const Error when no Compiler Const exists

"thejamie" <thejamie@discussions.microsoft.com>wrote in message

Quote
Wow - you guys are strange.



LOL



--

Reply to the group so all can participate

VB.Net: "Fool me once..."



-

Re:Why Compiler Const Error when no Compiler Const exists

This problem recurred. My last fix was simply to find a class module that

was missing an Option Explicit reference and which had a great deal of

undefined variables (variants). Once I defined the variants with specific

variable types and restarted the error message went away. This afternoon, I

needed to create a script for OSQL. After running the script, I went back

into my project to see the duplicate definition error pop up again. Instead

my message came back. I took a different approach this time and removed all

the references and restored them one at a time. To my surprise, I had mixed

versions of Crystral Report viewer objects (craxdrt) - some v9 some v8.5,

some v7 and some v9.2. I reregistered the v9.2 (regsvr32) prior to re-adding

references and once again, I am able to run the program. I wonder now if the

duplicate definition doesn't occur due to the version conflict in Crystal's

viewer.





"thejamie" wrote:



Quote
I get an error for a duplicate compiler const. I have no compiler const in

my project. Any idea why this might happen?

--

Regards,

Jamie

-

Re:Why Compiler Const Error when no Compiler Const exists

This problem is solved. To recreate the problem, copy a library from:

...program files\common files\crystal decisions\2.0\bin

Register the library in a different place.

Example:

regsvr32 c:\somplace\mycrystallib.dll



The project attempts to use the original location.

The registered location has changed and now there are two copies of the same

library registered.



To fix this, restore the registration into the standardized folder:

...program files\common files\crystal decisions\2.0\bin



OR,

remove all the references in your project to the library so you can remove

the library and re-add the library from the "c:\somplace\" folder.



I chose to move it all back the way it was. Boy was that ever a dumb move

on my part.



"thejamie" wrote:



Quote
This problem recurred. My last fix was simply to find a class module that

was missing an Option Explicit reference and which had a great deal of

undefined variables (variants). Once I defined the variants with specific

variable types and restarted the error message went away. This afternoon, I

needed to create a script for OSQL. After running the script, I went back

into my project to see the duplicate definition error pop up again. Instead

my message came back. I took a different approach this time and removed all

the references and restored them one at a time. To my surprise, I had mixed

versions of Crystral Report viewer objects (craxdrt) - some v9 some v8.5,

some v7 and some v9.2. I reregistered the v9.2 (regsvr32) prior to re-adding

references and once again, I am able to run the program. I wonder now if the

duplicate definition doesn't occur due to the version conflict in Crystal's

viewer.





"thejamie" wrote:



>I get an error for a duplicate compiler const. I have no compiler const in

>my project. Any idea why this might happen?

>--

>Regards,

>Jamie

-

Re:Why Compiler Const Error when no Compiler Const exists

Oddly, there actually were two constants that were public and using the same

name but were written differently.



First one

Public Const MAX_LEN = 260



Second

Public Const MAX_LEN As Long = 260



It took the rewrite of a subroutine to discover this oddity. I removed one

and the strange message ceased. I'll bet there are those of you out there

who are skeptical about whether the IDE would allow this in the first place.

Apparently it did as both variables have been there for quite some time.

There was a third



Private Const MAX_LEN = 260 in a class.



Jamie



"thejamie" wrote:



Quote
I get an error for a duplicate compiler const. I have no compiler const in

my project. Any idea why this might happen?

--

Regards,

Jamie

-

Re:Why Compiler Const Error when no Compiler Const exists

It may be the enumerated constants. I moved some around and made one

particular set Public since I use it in many places throughout the program.

When I make it a public rather than a private enumerator set, the error

returns.



Example:

Public Enum MyEnum

eNone

eOne

End Enum



In another module

Public Enum MyOtherEnum

eNone

eSomethingElse

End Enum







--

Regards,

Jamie





"MikeD" wrote:



Quote


"thejamie" <thejamie@discussions.microsoft.com>wrote in message

news:EF318380-9038-4737-8086-072EFE43BCD3@microsoft.com...

>Bob,

>

>Version VB6 SP6.

>

>Error is straightforward:

>Modal header is "Microsoft Visual Basic"

>

>Message is "DUPLICATE DEFINITION"

>

>the message provides an OK and HELP option.

>

>I click OK and tried to open the program again - got the same message.

This

>happened after a compile.

>



You most likely have 2 procedures of the same name and within the same

scope. Since VB can't determine which one you intended to call, it raises a

duplicate definition error. Search your project for the procedure and limit

the scope of one of the procedures, or if the procedures are actually

identical, eliminate of them.



Mike







-

Re:Why Compiler Const Error when no Compiler Const exists

The VB6 compiler can't tell the two eNone enumerations apart. This is a

design bug in the compiler. The workaround is to prefix all enumeration

values with a unique (to the enum statement) prefix.



Mike Ober.



"thejamie" <thejamie@discussions.microsoft.com>wrote in message

Quote
It may be the enumerated constants. I moved some around and made one

particular set Public since I use it in many places throughout the

program.

When I make it a public rather than a private enumerator set, the error

returns.



Example:

Public Enum MyEnum

eNone

eOne

End Enum



In another module

Public Enum MyOtherEnum

eNone

eSomethingElse

End Enum







--

Regards,

Jamie





"MikeD" wrote:



>

>"thejamie" <thejamie@discussions.microsoft.com>wrote in message

>news:EF318380-9038-4737-8086-072EFE43BCD3@microsoft.com...

>>Bob,

>>

>>Version VB6 SP6.

>>

>>Error is straightforward:

>>Modal header is "Microsoft Visual Basic"

>>

>>Message is "DUPLICATE DEFINITION"

>>

>>the message provides an OK and HELP option.

>>

>>I click OK and tried to open the program again - got the same message.

>This

>>happened after a compile.

>>

>

>You most likely have 2 procedures of the same name and within the same

>scope. Since VB can't determine which one you intended to call, it

raises a

>duplicate definition error. Search your project for the procedure and

limit

>the scope of one of the procedures, or if the procedures are actually

>identical, eliminate of them.

>

>Mike

>

>

>









-

Re:Why Compiler Const Error when no Compiler Const exists



"Michael D. Ober" <mdo.@.wakeassoc..com>wrote in message

Quote
The VB6 compiler can't tell the two eNone enumerations apart. This is a

design bug in the compiler. The workaround is to prefix all enumeration

values with a unique (to the enum statement) prefix.





Why do you say it's a bug?



--

Mike

Microsoft MVP Visual Basic







-

Re:Why Compiler Const Error when no Compiler Const exists



Because the outer enum types are different. There is enough syntactical

information in the source to unambiguously distinguish between the two uses

of eNone. This is a design bug in the VB 6 parser, one that it shares with

many older C compilers, including MS VC++ 6, as well.



If the outer two enum types were the same, then you have a situation where

you have a duplicate definition - the compiler cannot distinguish between

them.



Mike Ober.



"MikeD" <nobody@nowhere.edu>wrote in message

Quote




"Michael D. Ober" <mdo.@.wakeassoc..com>wrote in message

news:utUa%23ijWFHA.3540@TK2MSFTNGP15.phx.gbl...

>The VB6 compiler can't tell the two eNone enumerations apart. This is a

>design bug in the compiler. The workaround is to prefix all enumeration

>values with a unique (to the enum statement) prefix.





Why do you say it's a bug?



--

Mike

Microsoft MVP Visual Basic















-

Re:Why Compiler Const Error when no Compiler Const exists

Like in www.freepascal.org where they offer a seperate namespace for each

unit ? Just a different way of doing things, like using a fingerprint to open

a door rather than a keycard rather than a metal key ? There's always a way

to get around opening doors, you can use a metal pick for metal latch locks,

a magnetic pick for magnetic key card locks, and you can get the fingerprint

by having the person touch a common object, dusting, raising the imprint and

then making a duplicate print (or perhaps the George W. Bush manner) ?



--

Jim Carlock

Please post replies to newsgroup.



"Michael D. Ober" <obermd.@.alum.mit.edu.nospam>wrote:

Because the outer enum types are different. There is enough syntactical

information in the source to unambiguously distinguish between the two uses

of eNone. This is a design bug in the VB 6 parser, one that it shares with

many older C compilers, including MS VC++ 6, as well.



If the outer two enum types were the same, then you have a situation where

you have a duplicate definition - the compiler cannot distinguish between

them.



Mike Ober.



"MikeD" <nobody@nowhere.edu>wrote:

Quote




"Michael D. Ober" <mdo.@.wakeassoc..com>wrote:

>The VB6 compiler can't tell the two eNone enumerations apart. This is a

>design bug in the compiler. The workaround is to prefix all enumeration

>values with a unique (to the enum statement) prefix.



Why do you say it's a bug?



--

Mike

Microsoft MVP Visual Basic





-