Use GetVolumeInformationA() in universal app(windows) - windows

I want to get information about the "c:\", but when I use GetVolumeInformationA() function it say undefined identifier GetVolumeInformationA..
I have already include this header:
#include <FileAPI.h >
#include <WinBase.h>
#include <windows.h>
and I did see there exist a declaration in FileAPI.h, what should I do to use GetVolumeInformationA?

Related

Why does this std::map not display in a useable way in the watch window of Visual C++?

I'm unable to view certain std::map in the watch window. Looking into the .natvis file, there are multiple implementations for std::map. Is there a way to select one or the other?
https://developercommunity.visualstudio.com/content/problem/1056550/im-unable-to-inspect-a-variable-of-type-stdmap-in.html
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <memory>
typedef std::shared_ptr<std::string> PTR_STRING;
typedef std::map<PTR_STRING, std::size_t> accessFunction2Order;
typedef std::set<accessFunction2Order> setOfAccessFunction2Order;
typedef std::map<std::vector<std::size_t>, setOfAccessFunction2Order> A2B;
typedef std::map<PTR_STRING, std::shared_ptr<A2B> > MAP;
int main()
{ MAP s{
{ std::make_shared<std::string>("asdasdasdasdasdasdasdasdasdasd"),
std::make_shared<A2B>()
}
};
const auto &r1 = *s.begin();
}
The map s cannot be watched (something regarding std::_Tree<> being displayed). Curiously a reference to the first element can.
The problem is caused by a (I think hardcoded) limit in the visual studio debugger.
In order to display one variable, the debugger is adapting what he finds in the .natvis file -- but he gives up after some fixed number of attempts to resolve a type.
The solution to this problem is to use something like std::any
(or boost::any for those of us not blessed with being able to use an uptodate C++ version)
to break this STL type into chunks the debugger can deal with.
This is of course only a workaround.
Let's hope that this problem will be solved soon.
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <any>
#include <memory>
typedef std::shared_ptr<std::string> PTR_STRING;
typedef std::map<PTR_STRING, long> accessFunction2Order;
typedef std::set<accessFunction2Order> setOfAccessFunction2Order;
#if 1
typedef std::map<std::vector<std::size_t>, std::any> A2B;
#else
typedef std::map<std::vector<std::size_t>, setOfAccessFunction2Order> A2B;
#endif
typedef std::map<PTR_STRING, std::shared_ptr<A2B> > MAP;
typedef std::shared_ptr<std::size_t> PTR_INT;
int main()
{ const MAP s{
{ std::make_shared<std::string>("asdasdasdasdasdasdasdasdasdasd"),
std::make_shared<A2B>()
}
};
}

Error 2 files include each other

i have this problems while trying to include 2 files each other:
./include/../include/../src/Socket/../LinuxClass/ThreadingPool.hpp:38:5:
error: ‘Client’ does not name a type
Client client;
I already find a solution about declaring the first class in the second files but the error is still there here is the 2 .h
#ifndef THREADINGPOOL_HPP_
#define THREADINGPOOL_HPP_
#include <functional>
#include <algorithm>
#include <queue>
#include "../Socket/Client.hpp"
#include "../Intefaces/IThread.hpp"
#include "Mutex.hpp"
#include "Thread.hpp"
#include "Condvar.hpp"
#include "Process.hpp"
class ThreadingPool {
public:
ThreadingPool(unsigned int num_thr);
~ThreadingPool();
void Add_fct(std::function<void()> job);
private:
enum States {LIVE, DIE};
std::vector<std::thread> thrdVec;
std::vector<States> states;
std::queue<std::function<void()>> jobs;
Mutex mtex;
Condvar cond;
Process pros;
Client client;
};
#endif /* !THREADINGPOOL_HPP_ */
And the second one
#ifndef CLIENT_HPP_
# define CLIENT_HPP_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <functional>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#define PORT 1043
#define METASIZE 1024
#include "check_cmd.hpp"
class ThreadingPool;
class Client {
public:
Client();
~Client();
void ifMessage(ThreadingPool * thrdPool);
private:
int csock;
struct sockaddr_in csin;
};
#endif
I think the problem you have is that you put # define (space between hashtag)
instead of #define (no space between hashtag)
i think the space between it causes the compiler to not
implement the code within client.hpp, because you are not getting a error
saying
client.hpp does not exist, instead a error saying client (the class) does not exist. without define being wrote correctly, the compiler pretty much skips past the code within #ifndef

'USB_Close': identifier not found... 'len': undeclared identifier...

I wrote a code that accesses LEDs on an FPGA. Anyway, I cannot successfully compile the following code in Visual Studio:
#ifdef STATS_LIBRARY_EXPORTS
# define LIBRARY_API __declspec(dllexport)
#else
# define LIBRARY_API __declspec(dllimport)
#endif
#include <windows.h>
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <conio.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include "C:\Cypress\Cypress Suite USB 3.4.7\CyAPI\inc\CyAPI.h"
_declspec(dllexport) int excite_LED(bool start, int on) {
int i;
USB_Open();
for(i=0; i<100; i++) // blink the LEDs for a few seconds
{
USB_BulkWrite(2, &i, 1); // send one single byte (= the value of i) to FIFO2
Sleep(50); // and wait 50ms
BulkOutPipe2->XferData((PUCHAR)&i, len); // send one byte (the value of i) to FIFO2
//Send command to FPGA
//status = !BulkOutPipe2->XferData(fpgaCommunicator, fpgaCommunicatorBytes);
}
USB_Close();
}
I am getting the following errors:
left of '->XferData' must point to class/struct/union/generic type
identifier "USB_Open" is undefined
identifier "USB_Close" is undefined
identifier "USB_BulkWrite" is undefined
identifier "len" is undefined
identifier "BulkOutPipe2" is undefined
cannot open source file "stdafx.h"
'USB_Open': identifier not found
'USB_Close': identifier not found
'USB_BulkWrite': identifier not found
'len': undeclared identifier
'BulkOutPipe2': undeclared identifier
How can I fix my code to get rid of these errors?
BulkOutPipe2 is a common define for EndPoint 3 in many samples, but its not set in CyAPI.h, so you need to set it yourself:
#define BulkOutPipe2 USBDevice->EndPoints[3]
Which you need to initialise:
CCyUSBDevice *USBDevice = new CCyUSBDevice(NULL, ...);
Len is also not defined:
LONG len= 512000;
USB_BulkWrite (and other USB_) looks like usb_bulk_write, which is part of the libusb api. But you are trying to use with the CyApi (which is a lot different), so remove those method calls.

unexpected end of file error in ffmpeg libavutils/common.h while compiling

I am compiling following simple code in ffmpeg.
#include "stdafx.h"
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
void main()
{
av_register_all();
}
all the ffmpeg headers i have included in project properties.
but i am getting the following error on compiling.
Error 1 error C1004: unexpected end-of-file found dev\include\libavutil\common.h 87 1
Regards
Mayank
Try define __STDC_CONSTANT_MACROS before including those headers to see if problem can be solved.
#include "stdafx.h"
extern "C" {
#define __STDC_CONSTANT_MACROS
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
};
See http://bigbang.waterlin.org/bang/using-ffmpeg-under-windows-visual-cpp-environment/
Regards zcy

Cannot compile boost::condition_variable cond_

I have a class with the following -
boost::condition_varaible cond_;
When I try and compile -
[rmitra#butterfly boost]$ make EXE=thread_safe_stack
g++ -L /usr/local/lib -lboost_thread -o thread_safe_stack thread_safe_stack.cpp
I get the following error -
thread_safe_stack.cpp:25: error: ‘condition_varaible’ in namespace ‘boost’ does not name a type
thread_safe_stack.cpp: In member function ‘void thread_safe_stack::push(const T&)’:
thread_safe_stack.cpp:34: error: ‘cond_’ was not declared in this scope
thread_safe_stack.cpp: In member function ‘void thread_safe_stack::pop(T&)’:
thread_safe_stack.cpp:42: error: ‘cond_’ was not declared in this scope
make: * [exe] Error 1
Please explain what the problem is.. I am using boost 1.54
I have the following headers included in my source file -
#include <boost/thread.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/exceptions.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/pthread/condition_variable_fwd.hpp>
#include <iostream>
#include <stack>
#include <iterator>
#include <algorithm>
You're spelling condition_variable wrong:
boost::condition_varaible cond_;
^^

Resources