Including <Windows.h> causes (unknown attribute"no_init_all") error - c++

Title says it all, started a new project in VS2017, included <iostream>, then when I went to include <Windows.h> (This is my first attempt at working with this header by the way), I got the error saying: unknown attribute"no_init_all"
Any idea what might be causing this?

OK, putting those comments into an answer ...
This bug is fixed in VS 2019, but as per this answer, in VS 2017 you can use:
#define no_init_all deprecated
or even just:
#define no_init_all

Related

VS 2019 C++ Missing symbols in pch.h

I've seen the related question regarding "_T()" not found. I have a console app. The "Debug" version of the console app compiles and runs fine. When I try to compile it as a "Release" version I first get hundreds of _T() Not Found. I tried adding #include <tchar.h> to pch.h which was completely ineffective. Based on what I found in the question about undefined _T() I read, I added the text
#ifdef _UNICODE
#define _T(x) L ## x
#else /* _UNICODE */
#define _T(x) x
#endif /* _UNICODE */
#include <tchar.h>
#include "framework.h"
to pch.h before #include "framework.h". The compiler noticed but now complained as follows:
Error C2039 '_tcscpy_s': is not a member of '`global namespace'' Anon C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\atlmfc\include\atlchecked.h 111
plus a few hundred other similar messages.
This is not the first time this has happened. Every project I've tried to build with VS2019 eventually has this happen to it. And, this happens compiling a completely pristine "pch.h" that I had not (initially) modified at all before this error occurred.
I've already tried deleting VS and reinstalling it. My OS is Windows 10 (64-bit)
The list of Include directories is the same for both the Debug and Release configurations.
I feel that this must be related to something in the way Visual Studio is configured, but mostly I need help fixing it. The compiler seems to be getting tangled up in its own header files. What can I do to analyze/fix this?
ADDENDUM:
Just since I started writing this question I have gone back to my project and tried the Debug version again. Now it is getting the same errors. And I made no changes since the previous time I built it earlier today.

identifier "DDRB" is undefined - VS code / Visual studio

I am getting the following error when using the identifier DDRB:
identifier "DDRB" is undefined
But, when I click “go to definition”, the IDE does shows that it can find them. The code also compiles without any problem. I was using VScode first and setting intellisense to "tag parser" did work, but it also got rid of the error checking. So, I switched over to Visual Studio, but the issue remains. In both cases I included the AVR library.
I have googled quite a bit and found some solutions, but most were outdated or did not work. What can I do to resolve this issue?
"minimal reproducible example:"
#include <avr\io.h>
int main() {
DDRB |= (1 << DD3);
}
I can reproduce same issue in VS2017, and this one can be resolved by adding the #define __AVR_ATmega32U4__ above the #include <avr\io.h> like this:
#define __AVR_ATmega32U4__
#include <iostream>
#include <avr/io.h>
int main()
{
DDRB |= (1 << DD3);
}
After adding the macro definition, VS Intellisense option can recognize them well and the issue goes away. More details refer to Kissiel's reply. Thanks to him!
If you don't want to paste this definition into almost every file:
press f1
find C/C++; Edit configurations (UI)
paste your mcu name in Defines section e.g __AVR_ATmega32U4__
It worked for me in vs code.

OpenCL 2.x(C++ bindings): undefined identifier

Edit: adding OpenCL.lib in library files section of visual studio solved the problem.
With cl2.hpp from this github repository pointed by khronos site, I get 60-70 similar errors when I try to compile a C++ dll project with OpenCL-C++-implementation functions to export.
'CL_DEVICE_QUEUE_ON_HOST_PROPERTIES': undeclared identifier
// I'm not using this, I'm newly converting a v1.2 C++ binding-based
// project to a v2.0 one
starting of the file is:
using namespace std;
#define __CL_ENABLE_EXCEPTIONS
#include <CL\cl2.hpp>
and the remaining lines are not underlined with red(visual studio). There are some compile time constants I need to add maybe, but I don't know which constants.
What is missing?
this code(there isn't any other code in project) also gives same error:
#include <CL\cl2.hpp>
I had the same errors and something that worked for me was to add the following prior to #include <cl2.hpp>
#define CL_HPP_TARGET_OPENCL_VERSION 120
#define CL_HPP_MINIMUM_OPENCL_VERSION 120
#include <cl2.hpp>

HYPRE blas build error with VS 2015

I installed VS 2015 Professional. I installed the latest HYPRE, from the Lawrence Livermore website. I then configured it using CMake and proceeded to build, and I started getting BLAS (dnrm2.c) build errors:
2> dnrm2.c
2> 1>
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\math.h(454): error C2059: syntax error: '('
The line of code triggering the error in dnrm2.c is:
#include "math.h"
which points to the file:
c:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\math.h
I looked up this error and found some suggestions such as this to change the include to:
#include <cmath>
and to edit the HYPRE project settings in: Configuration > C/C++ > Advanced > Compile As to Compile As C++ (/TP)
which I did, but I still see same error, since apparently the same header path to math.h is included from cmath as well:
#else /* _STD_USING */
#include <math.h>
#endif /* _STD_USING */
I've even tried re-installing VS 2015 without any luck (same errors). Appreciate any ideas on what's going on here, and how to resolve this. I guess I could try a minimalist example in VS 2015 that includes the math.h and report back, if that helps.
EDIT
My minimalist example:
#include "math.h"
int main() {
double d1 = sqrt(4.0);
float d2 = abs(4.0);
return 0;
}
appears to be building OK. I tried to set the project the same way to Compile as C (or C++, didn't matter). This doesn't really help me though.
OK, the problem here is with HYPRE source it looks like. They have this in a file f2c.h included before including the math.h:
//#undef abs
//#define abs(x) ((x) >= 0 ? (x) : -(x))
//#endif
When I commented it out (since this is already defined in the standard), then it gets past that build error. Of course I run into other build errors. I'm trying to tackle those separately.
EDIT: It's not as simple as that because they (HYPRE) actually rely on their own definition of abs. So I had undo the above and change the order of some includes so that the undef actually made sense. Either way, this is a HYPRE source code problem.
If you succeed in compiling the HYPRE on VS2015, Could you send your VS2015 program to me!
My major is Geophysics modeling and inversion.
MY email is schoolhui#hotmail.com
Thank you very much!
I've just commented
_Check_return_ int __cdecl abs(_In_ int _X);
in
c:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\math.h
and then HYPRE was successfully compiled!
Then, I've uncommented "abs".

Boost / Netbeans: Recursive Includes Related to BSD on Linux Mint 17.2

I have a C++ project in Netbeans on my Linux Mint 17.2 machine. I'm using the GCC 5 toolchain (e.g. g++ 5.3.0), Netbeans 8.1, and Boost 1.61.0.
I'm encountering a weird warning in my project that shows up all over the place. For instance, in my main.cpp, I #include <iostream> at the very top, and that line gets a warning. (I see this warning happen for the first file I include in every file, so it is not an issue with iostream etc.).
The warning is that there is a recursive #include in boost. Specifically, Netbeans complains that <boost/predef/os/bsd/free.h> includes <boost/predef/os/bsd.h> and that <boost/predef/os/bsd.h> includes <boost/predef/os/bsd/free.h>. For the record, this appears to be true - does anyone know why there is this recursive include in boost, and if it is really supposed to be there?
The bigger issue is that my system is not BSD, so I don't know why I'm getting these warnings from the BSD headers, which shouldn't be included or active/defined. I tried printing BOOST_PLATFORM_CONFIG from my main.cpp, and it prints out the path to boost's Linux config header, as expected - not the BSD config header. And, my program compiles and runs fine, so I'm assuming it's never actually using the BSD headers. Which means that the fact that these BSD headers are giving me warnings might be a Netbeans problem, not a boost problem.
Does anyone have any ideas on how to narrow down and fix this issue with these strange recursive include warnings?
I was having the same problem. The issue is with the boost predef/os/bsd.h header. It #includes 5 files in the #else block for the #ifndef BOOST_PREDEF_OS_BSD_H guard. This means that this header file is not guarded against recursion if any of those 5 files also includes bsd.h (which they do).
My solution was to edit the predef/os/bsd.h file and add a recursion guard in the #else block - so, starting at around line 94 my predef/os/bsd.h file now looks like:
#ifndef BOOST_PREDEF_OS_BSD_H_PREVENT_RECURSION <-- ADD THIS
#define BOOST_PREDEF_OS_BSD_H_PREVENT_RECURSION <-- ADD THIS
#include <boost/predef/os/bsd/bsdi.h>
#include <boost/predef/os/bsd/dragonfly.h>
#include <boost/predef/os/bsd/free.h>
#include <boost/predef/os/bsd/open.h>
#include <boost/predef/os/bsd/net.h>
#endif <-- ADD THIS
And now netbeans code assistance is happy and my code still links and compiles without error.
The rough way: comment
#include <boost/predef/os/bsd.h>
Everywhere (should be inside the following headers)
predef/os.h
predef/other/endian.h