Is there a Windows equivalent of EDQUOT? - visual-studio

I'm porting some C++ code from UNIX to Windows which detects the occurrence of the EDQUOT error, which indicates that there was an unsuccessful attempt to exceed the current user's disk quota. Visual Studio's <errno.h> doesn't have an EDQUOT, although I know that Windows has disk quota functionality. Visual Studio's <errno.h> does have an ENOSPC, which might be how the CRT expresses what UNIX would express as EDQUOT. Can anybody confirm or deny this theory? And if this isn't the way to handle this, what is?

C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\WinSock.h
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\WinSock.h
#if 0
#define EDQUOT WSAEDQUOT
#endif
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\WinError.h
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\WinError.h
//
// MessageId: WSAEDQUOT
//
// MessageText:
//
// Ran out of disk quota.
//
#define WSAEDQUOT 10069L

Related

error RC2247: Symbol name too long (winnt.h)

I'm getting an RC2247 error (Symbol name too long) when attempting to display the dialogs in a Win32 app. The error is occurring in this file:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\winnt.h
This worked fine under VS2015. The error started when I upgraded to VS2017.
I have seen the following posts, they don't appear to be relevant because they pertain to prsht.h:
RC2247 : Cannot open Rc file : Resource explorer cannot load resource ; Load failed
http://social.msdn.microsoft.com/Forums/en-US/vcprerelease/thread/4a648d6a-ea81-44d3-89c2-57fa5caa6fd6
The error disappears if I comment out the entire resource.rc file. The error occurs if the RC contains the single line:
#include <winnt.h>
When I click on "Edit code"", nothing happens.
I am grateful for any suggestions.
We must not include windows.h or winnt.h to .rc file - this headers - for are for c/c++ compilers and not designed for RC (resource compiler which process .rc file). as result if we include such files we may get errors.
We need include #include <winres.h> to .rc files. this file specially designed for the RC compiler. Internally it included:
#include <winuser.rh>
#include <commctrl.rh>
#include <dde.rh>
#include <winnt.rh>
#include <dlgs.h>
#include <winver.h>
and define some macros.
All standard windows definitions, which we need/use in rc file - exist in winres.h (and it subincludes). From another side in it no extra symbols/definitions wich exist in windows.h - it's not needed for rc and some time can cause errors.
So simply #include <winres.h> at the beginning of resource files and all will be OK.
I have run into this complaint rc2247 when trying to edit the rc file in a project compiled in vs2010. This had been upgraded from vs2050. I found that if I chose to open the .sin file via 'version selector' instead of going straight to vs2010, then it still opens in vs2010 but there is no problem in editing the rc. I don't pretend to understand !
CalendarMan

The function async leaks memory on Windows

In an application of mine, I introduced a memory leak when I began to use std::async. After examining the problem with the tool Dr. memory, I found out that std::async leaks memory very often.
I made a quick test that reproduces the problem:
#include <Windows.h>
#include <algorithm>
#include <future>
using namespace std;
void testMethod()
{
for (int i = 0; i < 4; i++)
Sleep(10);
}
int main()
{
for (int i = 0; i < 100; i++)
{
auto result = async(launch::async, testMethod);
result.wait();
}
return 1;
}
How is it possible that the code above will leak memory on Windows? The problem does not occur on Linux. Dr. memory will produce the following log:
Error #1: REACHABLE LEAK 40 direct bytes 0x007badb8-0x007bade0 + 0 indirect bytes
# 0 replace_operator_new_nomatch [d:\drmemory_package\common\alloc_replace.c:2732]
# 1 MSVCR120D.dll!Concurrency::details::SubAllocator::Alloc [f:\dd\vctools\crt\crtw32\concrt\suballocator.cpp:201]
# 2 MSVCR120D.dll!Concurrency::details::ExternalContextBase::Alloc [f:\dd\vctools\crt\crtw32\concrt\externalcontextbase.cpp:238]
# 3 MSVCR120D.dll!Concurrency::Alloc [f:\dd\vctools\crt\crtw32\concrt\suballocator.cpp:34]
# 4 Concurrency::details::_AllocBase::operator new [c:\program files (x86)\microsoft visual studio 12.0\vc\include\concrt.h:298]
# 5 Concurrency::task<>::_TaskInitWithFunctor<> [c:\program files (x86)\microsoft visual studio 12.0\vc\include\ppltasks.h:3982]
# 6 Concurrency::task<>::_TaskInitMaybeFunctor<> [c:\program files (x86)\microsoft visual studio 12.0\vc\include\ppltasks.h:4551]
# 7 Concurrency::task<>::task<><> [c:\program files (x86)\microsoft visual studio 12.0\vc\include\ppltasks.h:4198]
# 8 Concurrency::create_task<> [c:\program files (x86)\microsoft visual studio 12.0\vc\include\ppltasks.h:4673]
# 9 std::_Task_async_state<>::_Task_async_state<><> [c:\program files (x86)\microsoft visual studio 12.0\vc\include\future:906]
#10 std::_Get_associated_state<> [c:\program files (x86)\microsoft visual studio 12.0\vc\include\future:1859]
#11 std::_Async<>

Linking to winmm.dll in Visual Studio 2013 Express for mciSendString

I am trying to use mciSendString in visual studio express 2013 (Visual C++) but I keep getting an error
Error 1 error C3861: 'mciSendStringA': identifier not found
I assume this i because I have not linked to the correct dll, but I cannot find any details online or on msdn about how to link to the dll. It seems quite strange that there wouldn't be more obvious documentation about this. Can someone tell me how to link to the dll?
EDIT:
Here is the code I am trying to run:
#include <Windows.h>
#include <iostream>
#include <mmsystem.h>
extern char command1[] = "open C:\\boing.mp3 type MPEGVideo alias 0";
extern char command2[] = "play 0 from 0";
int main()
{
mciSendStringA(command1, NULL, 0, 0);
mciSendStringA(command2, NULL, 0, 0);
}
To make mciSendString() to work, you need to link to winmm.lib.
Just adding winmm.lib to Project Properties > Linker > Input > Additional Dependencies will be fine.
Looking at mmsystem.h (admittedly from the V7.1A Windows SDK, which is the most recent I have installed), I can see that there's a #ifdef _WIN32 block in there. If _WIN32 is not defined, then mciSendStringA is not declared. Instead mciSendString is declared.
Check your project options and ensure that both WIN32 and _WIN32 are defined. I'm guessing that you started from a console project, rather than a Windows Application project, and that at least one of those isn't defined.

Microsoft MPI doesn't run

I'm trying out Microsoft's implementation of MPI. I installed the CCP sdk from here:
http://www.microsoft.com/en-us/download/details.aspx?id=239
And then in my project settings I added the include folder, the lib folder and mentioned msmpi.lib.
With the remaining settings as-is, I build the program and then in the command prompt I proceed to run the program, but nothing happens after I start it up.
Here's the code (It's supposed to display the id numbers for each thread):
#include "stdafx.h"
#include "mpi.h"
#include <stdio.h>
//Commands in cmd prompt
//cd "C:\Program Files\Microsoft Compute Cluster Pack\Bin"
//mpiexec.exe -n 2 "C:\Users\MyNameHere\Documents\Visual Studio 2012\Projects\tspMpi\Debug\tspMpi.exe"
int main(int argc, char* argv[])
{
int nTasks = 0, rank = 0;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&nTasks);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
printf ("Number of threads = %d, My rank = %d\n", nTasks, rank);
return 0;
MPI_Finalize();
}
As soon as I run mpiexec.exe (the commands are in the comments) the program just does nothing, until I press Ctrl-C. Does anyone know what I'm doing wrong? There are no errors when I build the program, and if I run it from visual studio, it acts as if there was only one process started up.
I didn't find SDK useful at all, here are my steps to enable MPI cluster debugging in VS 2010 (VC10):
step 1. Install MS-MPI: http://www.microsoft.com/en-us/download/details.aspx?id=36045 (x64 only), this creates
C:\Program Files\Microsoft HPC Pack 2012\Inc
C:\Program Files\Microsoft HPC Pack 2012\Lib\amd64
C:\Program Files\Microsoft HPC Pack 2012\Lib\i386
step 2. Download example: http://msdn.microsoft.com/en-us/library/ee441265(v=vs.100).aspx#BKMK_debugMany
step 3. Debugging setting: Right click on the Startup Project > Properties > Debugging
Debugger to launch, change "Local Windows Debugger" to "MPI Cluster Debugger"
Run Environment, change "localhost/1" to "localhost/4"
Right click on Visudal Studio Toolbar area to check "Debug Location", now you can switch Process and its Threads in the Debug Location toolbar, have fun!

compiler error in MS visual studio 2010

I am compiling my C source code in MS visual Studio C++ 2010.I am getting following following errors while building. What can be the reasons for it?
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/time.h(18): error C2061: syntax error : identifier 'suseconds_t'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/time.h(19): error C2059: syntax error : '}'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/time.h(37): error C2079: 'it_interval' uses undefined struct 'timeval'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/time.h(38): error C2079: 'it_value' uses undefined struct 'timeval'
[EDIT ]
Following is the code in my program:
#ifndef _DWORD_DEFINED
#define _DWORD_DEFINED
typedef unsigned long DWORD;
#endif
int getTime(struct timeval * tp, void * tzp)
{
DWORD milliseconds;
milliseconds = timeGetTime();
tp->tv_sec = milliseconds / 1000;
tp->tv_usec = (milliseconds % 1000) * 1000;
return 0;
}
Without any code, all I can say is this:
The first error cause is this.
The second error cause is this.
The third and fourth error cause is this.
Edit: After the OP's edit, the errors are more than obvious. Look at the struct timeval.
Where is it's definition? You access members of that struct and still you there is no visible definition of the struct.

Resources