dirent.h casuing problems with ShellAPI.h - c++

I have a function:
SHFileOperationFunc(string item1, string item2, int operation, CuTest *tc)
It is used to do operations (move, delete or copy) directories. It works fine. But i am now trying to use stuff from dirent.h. When I include the file it causes huge problems with stuff from ShellAPI.h I use in SHFileOperationFunc. I got dirent.h as per http://www.softagalleria.net/dirent.php.
After I include the file I get errors like:
error C2065: 'FO_DELETE' : undeclared identifier
error C2065: 'FO_COPY' : undeclared identifier
error C2065: 'FO_DELETE' : undeclared identifier
error C2065: 'FO_DELETE' : undeclared identifier
These are defined in ShellAPI.h. When I hover over them in VS it says the value they have so it is seeing them. Anyone know why including this file is having this effect?

Using dirent.h on a Windows machine is unadvisable, it is a Unix header. The file you downloaded screws up the rest of your #includes. Either put if after #include <windows.h> or edit the file and delete the #define for WIN32_LEAN_AND_MEAN. Putting that in a header is, well, mean. It causes a large number of declarations to be skipped in the Windows headers.

Related

How can I fix SFML errors in VS 2019 on windows?

I followed a video on LinkedIn to setup SFML, but when I tried compiling the code get several errors, some of which are:
C2065 'Fullscreen': undeclared identifier
C3861 'RenderWindow':identifier not found
C2871 'sf': a namespace with this name does not exist
C2653 'Style':is not a class or namespace name
C2065 'VideoMode':undeclared identifier
C3861 'vm' :identifier not found
C2065 'vm' :undeclared identifier
C26444 Don't try to declare a local variable with no name(es.84)
C2146 syntax error:missing ';' before identifier 'vm'
Assuming (from its name) that "pch.h" generates and/or uses the precompiled header for your build, then that has to be the very first header included in any source file. Otherwise, anything 'gleaned' from headers included before it will be lost, as the compiler only looks in that precompiled header and files included afterwards.
So, just rearrange your top three lines as follows:
#include "pch.h" // MUST be the first header included!
#include <iostream>
#include <SFML/Graphics.hpp>
For an interesting (and informative) discussion about precompiled headers in Visual Studio, see this Stack Overflow question, and the answers there: Precompiled Headers.

building example of canopen from canfestival error

I've got canopen source from canfestival.
I got errors when I built its win32test example on visual stdio,
there wasn't any lib file in file that I downloaded and extracted.
any help would be appreciated.
the errors:
error C2065: 'win32test_obj100C': undeclared identifier
error C2065: 'win32test_obj100D': undeclared identifier
there was a problem in built object dictionary
I make another object dictionary header and source with its .od file in cygwin and the errors gone

Why is my code not compiling when including OpenCV in my Visual Studio Project?

There is too much code to post so I'll be short and sweet here.
I'm migrating a project to Visual Studio that I originally built in Eclipse on OSX, using the OpenCV Apple framework distribution (opencv delivered as a .framework).
I've created a visual studio project from the existing code but when I build it, I get a bunch of errors from one of the headers (opencv2/core/fast_math.hpp) that are included along the header chain of <opencv2/opencv.hpp>.
1>c:\users\blah\tools\lib\opencv\build\include\opencv2\core\fast_math.hpp(105):
error C2065: '__m128d': undeclared identifier
1>c:\users\blah\tools\lib\opencv\build\include\opencv2\core\fast_math.hpp(105):
error C2146: syntax error: missing ';' before identifier 't'
1>c:\users\blah\tools\lib\opencv\build\include\opencv2\core\fast_math.hpp(105):
error C2065: 't': undeclared identifier
1>c:\users\blah\tools\lib\opencv\build\include\opencv2\core\fast_math.hpp(105):
error C3861: '_mm_set_sd': identifier not found
1>c:\users\blah\tools\lib\opencv\build\include\opencv2\core\fast_math.hpp(106):
error C2065: 't': undeclared identifier
Nothing has really changed in my code, just that I'm now using Visual Studio 2017. I have added opencv\build\include to my include path. I see that this code is SIMD intrinsics, which I don't think should have any problem compiling.
Is there a step I'm missing here?
This looks to be something with how I set up the project. The SIMD intrinsics require extra headers. I didn't configure the project to use precompiled headers which also appears to explain why std::string was undefined too. The extra headers can be added in stdafx.h and it's presence resolves other missing components.

Boost C++ libraries generating strange errors

I recently tried to write a c++ program, where I used the build in socket tools you can find in the Boost library. First of all, I tried to make a client/server based program, where the server just sends a message and the client receives it. It worked just fine.
Then I wrote another program, where I used a Xbox 360 kinect, to control my movement. The idea of creating the first program, was the get the code for the socket creating, so I can connect with, i.e. my Samsung tv, to control the tv, using my kinect.
The problem arises, when I copy my code from the first program, into my second program with the kinect. All of sudden, the program gives 100+ error, when compiling the boost library.
I triple checked the including libraries and all, but the problem still arises. Some of the errors are posted below:
1>C:\boost_1_55_0b1\boost/asio/detail/socket_types.hpp(96): error C2143: syntax error : missing ';' before '.'
1>C:\boost_1_55_0b1\boost/asio/detail/socket_types.hpp(96): error C2238: unexpected token(s) preceding ';'
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2224): error C2653: 'Windows' : is not a class or namespace name
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2224): error C2871: 'Collections' : a namespace with this name does not exist
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2225): error C2653: 'Windows' : is not a class or namespace name
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2225): error C2871: 'Networking' : a namespace with this name does not exist
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2226): error C2653: 'Windows' : is not a class or namespace name
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2226): error C2871: 'Connectivity' : a namespace with this name does not exist
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2227): error C2065: 'IVectorView' : undeclared identifier
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2227): error C2065: 'HostName' : undeclared identifier
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2227): error C2059: syntax error : '>'
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2227): error C2653: 'NetworkInformation' : is not a class or namespace name
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2228): error C2065: 'hostnames' : undeclared identifier
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2228): error C2227: left of '->Size' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>C:\boost_1_55_0b1\boost/asio/detail/impl/socket_ops.ipp(2230): error C2065: 'HostName' : undeclared identifier
And many many others. I know by the fact, that the libraries work. It worked in the first program, so I just can't figure out what's causing the problem.
Other includes are the SDL and SDK for Kinect libraries for c++.
I just came across this too. I found by adding the "/P" option to the C++ compiler options in Visual Studio and recompiling the file that failed, that s_addr was indeed getting #defined.
The offending header was part of the Windows SDK inaddr.h, which is included in the header chain of winsock.h.
The offending line in the header was:
#define s_addr S_un.S_addr
More information about this header is on MSDN here.
The fix I found was to #undef s_addr just before the #include of the BOOST ASIO header.

error C2065: 'errno' : undeclared identifier in <string> in Visual Studio 2012

I had a project running in Visual Studio 2010. Now I am using Visual Studio 2012.
Now I am getting below error while building the project.
I have looked into Google and SO as well. But no where I got any solution.
c:\program files\microsoft visual studio 11.0\vc\include\string(557): error C2065: 'errno' : undeclared identifier
2>c:\program files\microsoft visual studio 11.0\vc\include\string(557): error C2065: 'errno' : undeclared identifier
2>c:\program files\microsoft visual studio 11.0\vc\include\string(562): error C2065: 'errno' : undeclared identifier
2>c:\program files\microsoft visual studio 11.0\vc\include\string(574): error C2065: 'errno' : undeclared identifier
2>c:\program files\microsoft visual studio 11.0\vc\include\string(579): error C2065: 'errno' : undeclared identifier
I have tried with including stdlib.h into the sting header file but still I am getting this same error.
Any help appreciated.
There could be several possible reasons for this problem. The
first thing you should do is to create a one line source:
#include <string>
and nothing else, and try to compile it. If this doesn't
compile, there is a problem with your installation, and you
should reinstall it. Then, just to be sure, delete everything
in your source tree except the actual sources, project files and
solution, and rebuild. There may be some old files laying
around which are somehow causing the problem. I doubt it, but
this is something you should do anyway, any time you upgrade
a compiler, or even just install a patch. (If you've got
everything under source code control, which you should, the
simplest solution is just to delete everything, and do a new,
clean checkout.)
If these measures don't solve the problem (and somehow,
I suspect they won't), there's a problem in your code base
somewhere. errno is required to be a macro by the standard;
to get the error message you cite, the macro must be undefined.
<string> includes (indirectly) a file which defines it. Given
this, the only cause I can think of is that an earlier include
file has already included a file which defines errno, and then
#undefed it. To verify this, put your #include <string> as
the very first include of your source, and see if this solves
the problem. If it does, then you have to find the file which
does the #undef, and fix it.
I had the same issue. Strangely enough, the problem was not including "using namespace std;" under the header file includes. Apparently, program would recognize "string" unless I did this, even though "char", "float", etc were recognized.