Thread: Visual Studio C Help

  1. #16
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by robwhit View Post
    Did you #include "hashtable.h" in countwords.c?
    Function prototypes are automatically extern. You don't need to put the extern there.
    Yes, check out my code above. I still don't understand the "undeclared identifiers" though?

  2. #17
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Aw, screw it

    Nevermind

    Thanks for the help guys but this project is due in 2 days. I really don't have time to be debugging something that already works fine when I use Putty, especially since they'll be testing it in Unix anyway. Again, thanks the help

  3. #18
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by Paul22000 View Post
    Yes, check out my code above. I still don't understand the "undeclared identifiers" though?
    Undeclared identifiers means you didn't tell the compiler yet what some variable or function was. You might have told it later, or in a different file, but not that the compiler could see yet.

    I couldn't find countwords.c anywhere in this thread. Maybe it's somewhere in your project and you forgot about it?

  4. #19
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by robwhit View Post
    Undeclared identifiers means you didn't tell the compiler yet what some variable or function was. You might have told it later, or in a different file, but not that the compiler could see yet.

    I couldn't find countwords.c anywhere in this thread. Maybe it's somewhere in your project and you forgot about it?
    Oh, countWords.c is what I've been referring to "main.c" in this thread (for simplicity)

  5. #20
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    You appear to define LL_Element in hashTable.c. You need to do that in hashTable.h or it will not be visible outside of the hashTable.c file.

  6. #21
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    I think this was the problem, putting this in my hashTable.c:

    #ifndef HASHTABLE_H
    #define HASHTABLE_H

    Oops?

    I'm on campus right now so can't test it, but a buddy of mine did the same, ouch. Maybe there is hope for Visual Studio after all!

    Except that link error was pretty useless, gave no hints as to the above problem...

  7. #22
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Paul22000 View Post
    I think this was the problem, putting this in my hashTable.c:

    #ifndef HASHTABLE_H
    #define HASHTABLE_H

    Oops?

    I'm on campus right now so can't test it, but a buddy of mine did the same, ouch. Maybe there is hope for Visual Studio after all!

    Except that link error was pretty useless, gave no hints as to the above problem...
    Yeah, link errors are a big pain in the ass since they don't give you the line number of where the problem is the way compile errors do, but once you see enough of them, you'll start to understand the most likely causes for them.

  8. #23
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by cpjust View Post
    Yeah, link errors are a big pain in the ass since they don't give you the line number of where the problem is the way compile errors do, but once you see enough of them, you'll start to understand the most likely causes for them.
    Yeah, the line number would have been VERY helpful...

    Hate it when the errors are so simple like that, makes me want to pull my hair out!

  9. #24
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    Remember: Visual Studio is not at fault here; your other compiler/IDE is. Including other source files is a big no-no.
    Now TWO files will have the same source - so there's bound to be more than one symbol with the same name which is not allowed.

    As for your error... LL_Element must be declared/defined somewhere, right? Probably in that .c file. Declarations for structs and such should be in headers. And all source files that needs to use them includes that header. Simple.
    You'll see that it should compile then.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #25
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    I'm guessing the reason it compiled on UNIX is that he probably wasn't linking both hashTable.obj & main.obj in the makefile, so the multiple definition problem wouldn't have appeared.

  11. #26
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by cpjust View Post
    I'm guessing the reason it compiled on UNIX is that he probably wasn't linking both hashTable.obj & main.obj in the makefile, so the multiple definition problem wouldn't have appeared.
    Maybe Unix is more forgiving with these types of errors? If it finds a way to still compile and run, then it will just go ahead (even if it's not what you want to do)?

  12. #27
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Can't tell unless you post the entire source and the makefile/build process.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM