CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15
  1. #1
    Join Date
    Apr 2009
    Posts
    1,355

    [RESOLVED] i need a correction about include files

    - we add new include folder on Visual C++ Directories(on properties);
    - imagine that Visual Studio have the same include file that the added directories.
    these effect can cause a warning about Macro Definition?
    (code C4005)

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: i need a correction about include files

    Quote Originally Posted by Cambalinho View Post
    - we add new include folder on Visual C++ Directories(on properties);
    - imagine that Visual Studio have the same include file that the added directories.
    these effect can cause a warning about Macro Definition?
    (code C4005)
    Maybe. Keep in mind that you can control the order of how VS loads onclude files if that helps.

  3. #3
    Join Date
    Apr 2009
    Posts
    1,355

    Re: i need a correction about include files

    Code:
    #include <D3D11.h>
    #include <D3DX11.h>
    #include <d3dx10.h>
    some orders can cause errors.. but the warnings still be the same

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: i need a correction about include files

    Let me clarify, in the VS settings, you can change the load order for the directories of where the include files are located.

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: i need a correction about include files

    Why are you including both D3DX11.h and D3DX10.h?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #6
    Join Date
    Apr 2009
    Posts
    1,355

    Re: i need a correction about include files

    yes.. because of the D3DXCOLOR, i belive

  7. #7
    Join Date
    Apr 2009
    Posts
    1,355

    Re: i need a correction about include files

    even so, and i tested, the problem isn't that. i changed with float array, but the warnings are there

  8. #8
    Join Date
    Apr 2009
    Posts
    1,355

    Re: i need a correction about include files

    after more search i found 1 'solution':
    Code:
    #pragma warning (disable : 4005)#pragma warning (disable : 4838)
    
    
    #include <Windows.h>
    #include <string>
    #include <functional>
    #include <D3D11.h>
    #include <D3DX11.h>
    #include <d3dx10.h>
    #include <xnamath.h>
    isn't a solution, but avoid that errors. if i don't create them, i can't fix it.... so i belive that i hide them.
    thanks for all

  9. #9
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: [RESOLVED] i need a correction about include files

    The issue with ignoring warning c4005 is that as the macro is defined more than once, the last definition is used. This may be or may not be what is required - and the effect may differ depending upon the order of the definitions and as what the macros are defined. Have you found where the macros are defined - and the difference in their definitions? Often macro redefinition is avoided by testing that the macro is not already defined before defining it.

    c4838 concerns narrowing conversion (eg long long int to int etc). This usually means that there could be a problem somewhere. If an explicit narrowing is required then this is usually indicated by an explicit cast (static_cast).

    If these occur in 3rd party libraries which can't be changed, then it is better to just disable those warnings for the specific #include - often using push and pop. See https://msdn.microsoft.com/en-us/library/2c8f766e.aspx - and documented in the code!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  10. #10
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [RESOLVED] i need a correction about include files

    the D3D11.h and others(in these situation) are from DirectX SDK june 2010. i download it from MSDN... so isn't my error.
    yes all warnings are from DirectX headers inclued the
    xnamath(C4838).
    i had tried several ways of order, and the warnings are the same.
    i'm sorry, but these warnings are mine. so i can't avoid them... the #pragma just hide that warnings. but you have right, if i do that mistake after, i can't see the information, so it's bad or i just ignore them, because i can see the file name of the warning

  11. #11
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [RESOLVED] i need a correction about include files

    after reading and getting an idea, i did:
    Code:
    #pragma warning (disable : 4005)
    #pragma warning (disable : 4838)
    
    #include <Windows.h>
    #include <string>
    #include <functional>
    #include <D3D11.h>
    #include <D3DX11.h>
    #include <d3dx10.h>
    #include <xnamath.h>
    
    
    #pragma warning(default:4005)
    #pragma warning(default:4838)
    now i can ignore the warnings only on that include files. thank you so much for all

  12. #12
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: [RESOLVED] i need a correction about include files

    This would usually be coded as

    Code:
    #pragma warning (push)
    #pragma warning (disable : 4005 4838)
    
    #include <Windows.h>
    #include <string>
    #include <functional>
    #include <D3D11.h>
    #include <D3DX11.h>
    #include <d3dx10.h>
    #include <xnamath.h>
    
    #pragma warning(pop)
    Doing it this way also restores any warnings disabled within the include files.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  13. #13
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [RESOLVED] i need a correction about include files

    i'm sorry, these #pragma warning is ANSI C++?
    (yes the #pragma comment(lib, "libname.lib") isn't ANSI, because i can't use it with GNU C++ compiler)
    Last edited by Cambalinho; January 23rd, 2018 at 01:51 PM.

  14. #14
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: [RESOLVED] i need a correction about include files

    Quote Originally Posted by Cambalinho View Post
    i'm sorry, these #pragma warning is ANSI C++?
    (yes the #pragma comment(lib, "libname.lib") isn't ANSI, because i can't use it with GNU C++ compiler)
    The reference's I've provided are for MS Visual Studio which is all I use. Your original post #1 referenced Visual c++ which is MS VS. For other compilers you'll need to consult their documentation re use of #pragma - or perhaps some other guru could provide advice re the GNU compiler?
    Last edited by 2kaud; January 23rd, 2018 at 02:33 PM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  15. #15
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [RESOLVED] i need a correction about include files

    thank you so much for correct me. thank you to all

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured