-
January 22nd, 2018, 03:31 PM
#1
[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)
-
January 22nd, 2018, 03:37 PM
#2
Re: i need a correction about include files
Originally Posted by Cambalinho
- 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.
-
January 22nd, 2018, 03:58 PM
#3
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
-
January 22nd, 2018, 05:08 PM
#4
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.
-
January 23rd, 2018, 03:37 AM
#5
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)
-
January 23rd, 2018, 07:18 AM
#6
Re: i need a correction about include files
yes.. because of the D3DXCOLOR, i belive
-
January 23rd, 2018, 07:41 AM
#7
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
-
January 23rd, 2018, 08:24 AM
#8
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
-
January 23rd, 2018, 10:51 AM
#9
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)
-
January 23rd, 2018, 11:29 AM
#10
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
-
January 23rd, 2018, 12:15 PM
#11
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
-
January 23rd, 2018, 12:37 PM
#12
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)
-
January 23rd, 2018, 01:49 PM
#13
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.
-
January 23rd, 2018, 02:12 PM
#14
Re: [RESOLVED] i need a correction about include files
Originally Posted by Cambalinho
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)
-
January 23rd, 2018, 02:19 PM
#15
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|