Board index » Visual Studio » Why Compiler Const Error when no Compiler Const exists
|
JanetW
|
|
JanetW
|
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 - |
| Bob
Registered User |
Mon Dec 27 09:11:22 CST 2004
Re:Why Compiler Const Error when no Compiler Const exists
"thejamie" <thejamie@discussions.microsoft.com>wrote in message
QuoteI get an error for a duplicate compiler const. I have no compiler -- Reply to the group so all can participate VB.Net: "Fool me once..." - |
| thejamie
Registered User |
Mon Dec 27 09:25:05 CST 2004
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 |
| thejamie
Registered User |
Mon Dec 27 09:35:02 CST 2004
Re:Why Compiler Const Error when no Compiler Const existsUpdate: 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 |
| Bob
Registered User |
Mon Dec 27 09:46:24 CST 2004
Re:Why Compiler Const Error when no Compiler Const exists
"thejamie" <thejamie@discussions.microsoft.com>wrote in message
QuoteBob, 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..." - |
| thejamie
Registered User |
Mon Dec 27 11:14:15 CST 2004
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 |
| Bob
Registered User |
Mon Dec 27 12:44:09 CST 2004
Re:Why Compiler Const Error when no Compiler Const exists
"thejamie" <thejamie@discussions.microsoft.com>wrote in message
QuoteOption Explicit may have been the issue. I found a module that did -- Reply to the group so all can participate VB.Net: "Fool me once..." - |
| MikeD
Registered User |
Mon Dec 27 12:46:43 CST 2004
Re:Why Compiler Const Error when no Compiler Const exists"thejamie" <thejamie@discussions.microsoft.com>wrote in message QuoteBob, 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 - |
| Bob
Registered User |
Mon Dec 27 12:52:21 CST 2004
Re:Why Compiler Const Error when no Compiler Const exists
"MikeD" <nobody@nowhere.edu>wrote in message
<cut> QuoteYou most likely have 2 procedures of the same name and within the same "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..." - |
| thejamie
Registered User |
Mon Dec 27 13:11:03 CST 2004
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
|
| Kelly
Registered User |
Mon Dec 27 13:22:44 CST 2004
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... QuoteI definitely have procedures with similar names, but to the best of my - |
| Bob
Registered User |
Mon Dec 27 14:08:18 CST 2004
Re:Why Compiler Const Error when no Compiler Const exists
"Kelly Ethridge" <kelly@kellyethridge.com>wrote in message
QuoteI can get 'Duplicate Declaration' by having a Function the same name -- Reply to the group so all can participate VB.Net: "Fool me once..." - |
| Stefan
Registered User |
Mon Dec 27 16:42:13 CST 2004
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> QuoteAll I can get is "ambiguous name detected"; no matter what I try I can't get 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 - |
| Veign
Registered User |
Mon Dec 27 16:45:31 CST 2004
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 QuoteOn Mon, 27 Dec 2004 10:52:21 -0800, "Bob Butler" - |
| Stefan
Registered User |
Mon Dec 27 17:12:03 CST 2004
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> QuoteSomething that may be helpful is using mztools (www.mztools.com) to identify the error still shows up randomly after a long editing session. Exiting the IDE and restarting inevitably remedies the problem. --- Stefan Berglund - |
| Brian
Registered User |
Mon Dec 27 17:20:15 CST 2004
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
- |
| MikeD
Registered User |
Mon Dec 27 18:23:16 CST 2004
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 I've encountered the duplicate definition error. I can't reproduce it either though. - |
| Björn
Registered User |
Tue Dec 28 01:03:36 CST 2004
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 Try this: (from the msdn library) #Const Mac = 0 #Const Mac = 1 -- Björn Holmgren - |
| Bob
Registered User |
Tue Dec 28 07:19:30 CST 2004
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 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..." - |
| thejamie
Registered User |
Tue Dec 28 07:21:01 CST 2004
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 |
| Bob
Registered User |
Tue Dec 28 07:38:27 CST 2004
Re:Why Compiler Const Error when no Compiler Const exists
"thejamie" <thejamie@discussions.microsoft.com>wrote in message
QuoteWow - you guys are strange. -- Reply to the group so all can participate VB.Net: "Fool me once..." - |
| thejamie
Registered User |
Sat Feb 19 08:51:02 CST 2005
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: QuoteI get an error for a duplicate compiler const. I have no compiler const in |
| thejamie
Registered User |
Wed Feb 23 10:59:01 CST 2005
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: QuoteThis problem recurred. My last fix was simply to find a class module that |
| thejamie
Registered User |
Sun Mar 20 16:05:03 CST 2005
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: QuoteI get an error for a duplicate compiler const. I have no compiler const in |
| thejamie
Registered User |
Mon May 16 05:27:27 CDT 2005
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
|
| Michael
Registered User |
Mon May 16 12:00:18 CDT 2005
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 QuoteIt may be the enumerated constants. I moved some around and made one - |
| MikeD
Registered User |
Mon May 16 13:15:24 CDT 2005
Re:Why Compiler Const Error when no Compiler Const exists"Michael D. Ober" <mdo.@.wakeassoc..com>wrote in message QuoteThe VB6 compiler can't tell the two eNone enumerations apart. This is a Why do you say it's a bug? -- Mike Microsoft MVP Visual Basic - |
| Michael
Registered User |
Tue May 17 00:10:23 CDT 2005
Re:Why Compiler Const Error when no Compiler Const existsBecause 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
- |
| Jim
Registered User |
Tue May 17 01:40:48 CDT 2005
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
- |
