Thread: Visual Studio includes

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    6

    Visual Studio includes

    Hey guys,

    I was hoping to get some simple advice on this. I am wanting to setup my directory layout for my project as:

    Project
    include
    src

    I am also hoping to just be able to do #include "file.h" instead of having to do #include "include/file.h". Now, if I don't put the include directory path part of that it can't find its own files despite their being listed under the header files. Is there a way to set the project's include directory path in VS (specifically 2010)? The way I was using before was to include the project's own path in its include directories project settings but after upgrading to VS2010 it is now confusing the linker into thinking that 2 copies exist and as such is duplicating declarations.

    Thanks in advance,
    Aetas

  2. #2
    Registered User
    Join Date
    Sep 2010
    Posts
    6
    Just to add, this ONLY happens in VS2010. It seems like it is somehow finding the files twice and if any of you guys are familiar with Ogre3D this is also how they configure their include directories and this also happens in their projects as well. I just can't find a fix for this.....

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Aetas View Post
    The way I was using before was to include the project's own path in its include directories project settings but after upgrading to VS2010 it is now confusing the linker into thinking that 2 copies exist and as such is duplicating declarations.
    This should still work.
    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.

  4. #4
    Registered User
    Join Date
    Sep 2010
    Posts
    6
    It does, actually. But after doing so it starts listing each include file twice and when I try to link my project together, it is managing to bypass my include guard that should only allow that file to be included once otherwise. Here's the warning I'm getting:

    2>AuroraD3D9RenderSystem.obj : warning LNK4006: "struct Aurora::Gfx:3D9DisplayModeFormatEntry * Aurora::Gfx:3D9DisplayModeFormats" (?D3D9DisplayModeFormats@Gfx@Aurora@@3PAUD3D9Displ ayModeFormatEntry@12@A) already defined in AuroraD3D9Window.obj; second definition ignored
    2>AuroraD3D9Adapter.obj : warning LNK4006: "struct Aurora::Gfx:3D9DisplayModeFormatEntry * Aurora::Gfx:3D9DisplayModeFormats" (?D3D9DisplayModeFormats@Gfx@Aurora@@3PAUD3D9Displ ayModeFormatEntry@12@A) already defined in AuroraD3D9Window.obj; second definition ignored

    These are both in 1 include file that is included in both AuroraD3D9Window.h and AuroraD3D9RenderSystem.h except it is wrapped in an include guard. Somehow, that is getting bypassed and I don't understand why. I mean both of those files are in the same library....how is it bypassing the include guard?

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Where is 3D9DisplayModeFormats defined?
    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.

  6. #6
    Registered User
    Join Date
    Sep 2010
    Posts
    6
    AuroraD3D9Common.h
    http://pastebin.com/hxzgUfvx

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You realize that include guards protect the same source file from including the same header more than once, right?
    That means every source file will get its own D3D9DisplayModeFormats variable. That is where you warnings originate from.
    You should not define variables in headers. They should be defined in source files.
    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.

  8. #8
    Registered User
    Join Date
    Sep 2010
    Posts
    6
    Hrmm....so declare the variable in the common file and stick its initialization in a source file for it?

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Absolutely. And don't forget to put "extern" before your declaration.
    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. #10
    Registered User
    Join Date
    Sep 2010
    Posts
    6
    Alright, looks good. Appreciate the help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LDAP Query
    By Travoiz in forum C++ Programming
    Replies: 0
    Last Post: 08-13-2009, 02:58 PM
  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