Quantcast
Channel: Visual C forum
Viewing all 15302 articles
Browse latest View live

Visual Studio 2017 C++ with Windows 10 linux subsystem problem

$
0
0

Hello! I try compile c++ linux program using linux subsystem on windows 10 with openssl library, but qwhen i try compile i get error:

Error (active) E1696 cannot open source file "openssl/aes.h"

I have installed openssl library in default directory, include path is /usr/include/openssl. Il try add -I switch but still have this error. How can Il fix this ? Thank You for answer.


DirectoryWalker converting C# to C++/CLR

$
0
0

Hi All,

New to Visual Studio, get around a bit in C/C++ ... not a guru though!
Have my own DirectoryRecursion class that uses FindFirst/NextFile for straight C++ on Windows and fills a list<string>, Trying to achieve the same results using GetDirectories() and GetFiles().

VS Community 2015

Found this MS article How to recursively search folders by using Visual C++ and it fails to retrieve all files ...

void DirSearch(String^ sDir) { try { array<String^>^ d = Directory::GetDirectories(sDir); int numDirs = d->Length; for(int i = 0; i < numDirs; i++) { array<String^>^ f = Directory::GetFiles(d[i], tbxFilter->Text); int numFiles = f->Length; for(int j = 0; j < numFiles; j++) { listBox1->Items->Add(f[j]); // for testing, will convert to a enumerable collection of some sorts } DirSearch(d[i]); } } catch(System::Exception^ e) { System::Console::WriteLine(e->Message); } }

Didn't dig much into the above as I found this: Scanning a drive with drilldowns using C#? and have spent my time trying to convert it to C++/CLR without success, so in the flux of things here is where I am at with it. errors are marked // ERROR:

namespace DirectoryWalker { using namespace System; using namespace System::IO; using namespace System::Collections::Generic; public ref class DirectoryWalker : IEnumerable<String^> { private: String^ _seedPath; Func<String^, bool>^ _directoryFilter; Func<String^, bool>^ _fileFilter; public: DirectoryWalker(String^ seedPath) : this(seedPath, "", "") // ERROR: expected an identifier { // Syntax error: 'this' } // Not sure what to replace 'null' with. public: DirectoryWalker(String^ seedPath, Func<String^, bool>^ directoryFilter, Func<String^, bool>^ fileFilter) { if (seedPath->Equals(String::Empty)) throw gcnew ArgumentNullException(seedPath); _seedPath = seedPath; _directoryFilter = directoryFilter; _fileFilter = fileFilter; } virtual IEnumerator<String^>^ GetEnumerator() { Queue<String^>^ directories = gcnew Queue<String^>(); directories->Enqueue(_seedPath); Queue<String^>^ files = gcnew Queue<String^>(); while (files->Count > 0 || directories->Count > 0) { if (files->Count > 0) { return files->Dequeue; // ERROR: non standard syntax; use '&' to create a pointer to member } // 'return': cannot convert from 'System::String ^(__clrcall System::Collections::Generic::Queue<System::String ^>::* )(void)' to 'System::Collections::Generic::IEnumerator<System::String ^> ^' // At a loss here, understand the error, don't know how to fix it ... if (directories->Count > 0) { String^ dir = directories->Dequeue(); array<String^>^ newDirectories = Directory::GetDirectories(dir); array<String^>^ newFiles = Directory::GetFiles(dir); for each(String^ path in newDirectories) { if (_directoryFilter->Equals(String::Empty) || _directoryFilter(path)) directories->Enqueue(path); } for each(String^ path in newFiles) { if (_fileFilter->Equals(String::Empty) || _fileFilter(path)) files->Enqueue(path); } } } } virtual System::Collections::IEnumerator^ GetEnumerator2() = System::Collections::IEnumerable::GetEnumerator { return GetEnumerator(); } } }; // ERROR: expected a ';', syntax error: missing ';' before '}'

Not sure the override is correctly done.
Unsure of the use of Func(), never used it before.

The end goal, to have an enumerable collection of path/filenames.

Thank you
-Enjoy
fh : )_~

unresolved external symbol _MFCreateSinkWriterFromURL

$
0
0

Hi.

I am developing h264 encoding applicating using MEDIA FOUNDATION.

My code is derived from SinkWriter tutorial

https://msdn.microsoft.com/ru-ru/library/windows/desktop/ff819477(v=vs.85).aspx

Everything seems ok, except one error:

Error4error LNK2019: unresolved external symbol _MFCreateSinkWriterFromURL@16 referenced in function "public: long __thiscall Encoder::Setup(struct IMFSinkWriter * *,unsigned long *,int,int,int)" (?Setup@Encoder@@QAEJPAPAUIMFSinkWriter@@PAKHHH@Z)C:\*****\VideoServer\VideoServerC++\Encoder.objVideoServerC++

I have Windows SDK v7.1 installed onboard.

Libs and includes dirs seems ok.

There are C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\mfreadwrite.lib and C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\mfreadwrite.h on their places.

I tried x64 and x86 targets - error won't disappear.


Help me, please.




Why IsDlgButtonChecked not see CheckBox1 cheched

StringCchPrintf - problem

$
0
0

Hi,

I use VC++2008.

Multi-Byte character set

 

I have class with method:

 

void DoSomeThing( char* szIpAddr)

{
 //...char szTemp[2];

 ::StringCchPrintf( szTemp, 2, "%c", szIpAddr[i] );//...
}

 

When I include my class to Console project then all is OK.

 

But, when I include my class to Windows Forms project, then I got this error:

 

1>.\T_MyClass.cpp(222) : error C2039: 'StringCchPrintf' : is not a member of '`global namespace''
1>.\T_MyClass.cpp(222) : error C3861: 'StringCchPrintf': identifier not found

 

So I checked "::" namespace and I find only StringCchVPrintf

And I did like below:

 

void DoSomeThing( char* szIpAddr)

{
 //...char szTemp[2];

  va_list pArgs;     // LINE 222	 
  va_start(pArgs, szIpAddr[i]);  // LINE 223

  ::StringCchVPrintf( szTemp, 2, "%c", pArgs );

		va_end(pArgs);
 //...
}

 

And again error:

1>.\T_MyClass.cpp(223) : error C2143: syntax error : missing ')' before '['
1>.\T_MyClass.cpp(223) : error C2143: syntax error : missing ')' before '['
1>.\T_MyClass.cpp(223) : error C2109: subscript requires array or pointer type
1>.\T_MyClass.cpp(223) : error C2059: syntax error : ')'
1>.\T_MyClass.cpp(223) : error C2059: syntax error : ')'

I really i dont know what to do now,

 

please help me,





Inrernal application error

$
0
0

Hello,

I have following code , when i cam calling "throw new Derived()" it is showing error message "internal Application error."

==============================

class  Base :public CException
{
public:
    Base (void) {}
Base (const Base & src) {}
    ~Base (void) {}
};

class  Derived :public  Base
{
public:
    Derived (void) {}
   Derived (const Derived & src) {}
      ~Derived (void) {}
};

void CexpecDlg::OnBnClickedOk()
{

try{

throw new Derived();
int i=0;
AfxMessageBox(L"Try");
}
catch(Derived aa)
{
AfxMessageBox(L"Exception");
}
OnOK();
}

==============

Basically i was upgrading the our application from visual studio 2003 to 2008 . in 2003 i can call "throw Derived()" (without new) that was working fine. but after upgrading to 2008 i have to change "throw Derived()" to "throw new Derived()"

Please suggest i would not like to do major changes in the application as it may impact all depended classes.

Thanks,

Sushil Kumar

Why calling default constructor explicitly causes/makes errors, but no errors if it is called implicitly

$
0
0

This code compiles without any error:

#define _AFXDLL
#define _DLL
#include <afx.h>
#include <afxadv.h>
#define cxscreen GetSystemMetrics(SM_CXSCREEN)
#define cyscreen GetSystemMetrics(SM_CYSCREEN)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	CWnd cwnd; //implicitly call default constructor of CWnd
	RECT rect = { 0, 0, cxscreen, cyscreen };
	cwnd.Create("mdiclient","sierpinski triangle", WS_OVERLAPPEDWINDOW | WS_VISIBLE, rect, nullptr, 0);
}

But this code not, when I add (), explicitly call default constructor of CWnd, after cwnd:

#define _AFXDLL
#define _DLL
#include <afx.h>
#include <afxadv.h>
#define cxscreen GetSystemMetrics(SM_CXSCREEN)
#define cyscreen GetSystemMetrics(SM_CYSCREEN)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	CWnd cwnd(); //explicitly call default constructor of CWnd
	RECT rect = { 0, 0, cxscreen, cyscreen };
	cwnd.Create("mdiclient","sierpinski triangle", WS_OVERLAPPEDWINDOW | WS_VISIBLE, rect, nullptr, 0);
}

For the code above I get and have two errors:

error C2228: left of '.Create' must have class/struct/union

Intellisense: expression must have class type

Why!? There is no difference at all, if I call default constructor either implicitly or explicitly, and if there is no difference, then the results should be the same. If for implicit default constructor call I have no errors then for explicit default constructor call I should not have errors as well.

Windows 10 / bluetooth / API ::CreateFile(...)

$
0
0

When I pair Windows 10 with a HC05 bluetooth module I get two COM ports assigned to - one outgoing and one incoming.

These then appear in the registry under HKEY_LOCAL_MACHINE=>HARDWARE=>DEVICEMAP=>SERIALCOMM

So inside this registry folder I am searching for all the available com ports and then trying all combinations of  in and out ports (created via API ::CreateFile(...)) until I find the correct pair associated with my bluetooth modem.

This includes the possibility that the same COM port is used for both input and output.

In the current example I end up with COM3 (input) and COM4 (output) listed under HKEY_LOCAL_MACHINE=>HARDWARE=>DEVICEMAP=>SERIALCOMM.

However it turns out that COM3 is used for both input and output on my bluetooth modem.

So what is the point in windows 10 assigning COM4 to my bluetooth modem when it cannot be opened as a file and appears to serve no purpose???

I wish Microsoft would make their bluetooth software like Toshiba bluetooth stack - with this software my bluetooth modem gets assigned one single COM port and the whole process of identifying the correct COM port for my bluetooth modem is a lot simpler!


Linker Warning 81010002

$
0
0

Hi there,

The issue is as posted over Stack Overflow, but it hasn't generated a lot of excitement- unsure of whether posting here will change any, but please read on:

The hotfix as linked from this page only gets to the Answer Desk Virtual Agent chat which tends to put me in an infinite wait loop or onto other links which appear to go nowhere in particular.

Is there actually a newer version of mt.exe for Visual Studio 10 which suppresses the warning as described?

Thanks for response!


A natural, B flat, C sharp, D compile




_sntprintf behavior changed in VS 2015 from VS 2010

$
0
0

Hi, 

The value of result in below piece of code used to be 9 in Visual studio 2010 but now it's returning -1 in visual studio 2015. 

 

#define tsizeof(x) (sizeof(x) / sizeof(x[0]))      // number of elements in array

TCHAR abc[10] = TEXT("");
    int result;
    result = _sntprintf(abc, tsizeof(abc)-1, TEXT("%s%s"), TEXT("123456789"), TEXT("") );

This is just the customized part of issue. When our product recently ported to VS2015, this piece of code is not working. The last parameter is actually a variable which could be empty or non-empty. So the issue is seen when it's empty. Could you please help


Ashwin


python setup.py and cl.exe woes.

$
0
0

Hello, I'm trying to build a python module using python's setup.py tools. I have python 2.7 and VC C++ for Python 9.0 installed in:

C:\Python27
C:\Users\<user>\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\

When I run the script I get the following output:

C:\Users\<user>\Desktop\Test2>python setup.py build_ext -i
running build_ext
building '_acqMethods' extension
C:\Users\<user>\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.
0\VC\bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG "-IC:\Users\<user>\AppData\Local\Prog
rams\Common\Microsoft\Visual C++ for Python\9.0\VC\include" -IC:\Python27\includ
e -IC:\Python27\PC /TcacqMethods_wrap.c /Fobuild\temp.win32-2.7\Release\acqMetho
ds_wrap.obj
cl : Command line warning D9024 : unrecognized source file type 'C:\Users\<user>
\AppData\Local\Programs\Common\Microsoft\Visual', object file assumed
cl : Command line warning D9027 : source file 'C:\Users\<user>\AppData\Local\Pro
grams\Common\Microsoft\Visual' ignored
cl : Command line warning D9024 : unrecognized source file type 'C++', object fi
le assumed
cl : Command line warning D9027 : source file 'C++' ignored
cl : Command line warning D9024 : unrecognized source file type 'for', object fi
le assumed
cl : Command line warning D9027 : source file 'for' ignored
cl : Command line warning D9024 : unrecognized source file type 'Python\9.0\VC\b
in', object file assumed
cl : Command line warning D9027 : source file 'Python\9.0\VC\bin' ignored
acqMethods_wrap.c
c:\python27\include\pyconfig.h(239) : fatal error C1083: Cannot open include fil
e: 'basetsd.h': No such file or directory
error: command 'C:\\Users\\<user>\\AppData\\Local\\Programs\\Common\\Microsoft\\
Visual C++ for Python\\9.0\\VC\\bin\\cl.exe' failed with exit status 2

For some reason it seems that cl.exe is splitting the path on the spaces to the include path. The path is correctly being encased in quotations marks. Any ideas what else could be going on? Thanks in advance.

MFC in Windows 10

$
0
0
We have an MFC product built in Visual Studio in C++ that does many mathematical calculations.  We use floating point interrupts through the coprocessor to help speed up the calculations, by setting up try/catch blocks.  Those interrupts work well in Windows 7, but one of the updates for Windows 10 broke the sequence.  While the "signal" call still sets up the correct pointer for the "handler" callback,  Windows 10 ignores it.  (The same code works in a console program; it only fails in MFC code, even the simplest stripped example).  We have a workaround using SEH, but we would still like to know why this happened.  Thanks for any information.

Shadow stack in vectorcall calling convention

$
0
0

Hi,

According to vectorcall calling convention a shadow space should be allocated for vector types and HVAs on 64 bit architecture.

For each vector type or HVA aggreagte, 8 byte should be allocated.

Is the allocated shadow space in addition to the already allocated 32 byte? Will it reside before or after other arguments on the stack?


Thanks,

Oren

QState Transition doesn't work in c++/clr environment

$
0
0

Because of using dll, I changed Common Language Runtime Support in my QT project into Common Language Runtime Support (/clr) ( I use Qt 5.71 x86 in Visual Studio 2015)

i used: stateExploring->addTransition(ui.startExperiment, &QPushButton::clicked, stateRunning); to change from state "stateExploring" into "stateRunning" when button clicked, it seems that this function doesn't work

for debugging, I changed into No Common language support, this function worked well.

it is clear to there is problem in "addtransition" function when using runtime common language clr.

any one please help me an opinion to run this function in clr support environment

close one dialog from another dialog, how to do that ?

$
0
0
Hi, I am trying to close one dialog from another dialog, CDialog::OnClose() doesn't function well. is there any samples?

change static font text in a dialog

$
0
0

I am trying to change the font size in a static text control, but I got this error, "Error 94 error C4430: missing type specifier - int assumed. Note: C++ does not support default", it position the error at "CFont *font;", not sure why,

public:
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	CFont *font;
	virtual BOOL OnInitDialog();

BOOL TopBar::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	font = new Cfont();
	font->CreatePointFont(200,_T("宋体"),NULL);
    GetDlgItem(IDC_Static)->SetFont(&font);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

Visual Studio 2012: cannot open file 'gdi32.lib'

$
0
0

Hi, there:

I've encountered an issue when build with VS2012.

Build log of hello world:

1>------ Rebuild All started: Project: test, Configuration: Debug Win32 ------
1>Build started 2015/12/15 15:52:27.
1>_PrepareForClean:
1>  Deleting file "Debug\test.lastbuildstate".
1>InitializeBuildStatus:
1>  Touching "Debug\test.unsuccessfulbuild".
1>ClCompile:
1>  test.cpp
1>LINK : fatal error LNK1104: cannot open file 'gdi32.lib'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.56
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Then I searched around the disk and located the library file 'gdi32.lib' at the following paths:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64"

Platform: Windows 7 64bit Ultimate Edition

IDE:         Visual Studio 2012 Ultimate with Update 4

When typing 'set lib' in command prompt tools (32bit for instance) as the post:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\x86;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\ATLMFC\LIB;C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program
 Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64

So, could anyone show me some hint?

Thank you very much in advance!

================================================================

EDIT:

There's only one IDE (vs2012) on my machine and it is in good condition, until recently I installed another (vs2005), after that, vs2005 functions well while vs2012 fails....



Dynamic create combo box font size come bigger how to fix it.

$
0
0

Hi All 

I Try to create ComboBox at Runtime Here is my code

CComboBox *MyCom;// in .H file //======================================== MyCom = new CComboBox; MyCom->Create(CBS_HASSTRINGS | CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE, rc, m_pHWnd, 0x1448); CFont comboFont; comboFont.CreateFontW(18, 0, 0, 0, FW_BOLD, FALSE, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_NATURAL_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Arial")); MyCom->SetFont(&comboFont);

MyCom->AddString(L"Show");
MyCom->AddString(L"Hide");


What i miss or i did wrong.

Please Help.


VS 2017 C++ and NuGet GLFW3 / GLEW library linker error

$
0
0

I created a simple C++ console app in VS2017 RC. I added GLFW3 and GLEW via nuGet package manager. The problem is that the compiler reads the header files but the linker does not find the libraries / DLLs. I don't know what to do to include the DLLs / libs in the project.

Any tips or hints are appreciated.

MIDI programming in C++: winmm functions within callbacks

$
0
0

Hello, I haven't used this forum before, the following may be OT. If so, apologies to the moderator. If there is a better place to post this query, appreciate if someone could let me know.

I run my own MIDI software, running under Windows10, and programmed in WIN32 MFC, using the MS winmm.lib. It’s worked fine for years, but I’m always a bit on edge about the cautionary note that winmm functions should not be invoked inside callback functions, because there is a risk of deadlock. When I initially wrote my application I hadn’t seen this note, and now my code contains things like this when I want to immediately ship out an incoming message:

 

// MIDI input callback function

void CALLBACK MidiInCB(…..)

               {

               ……….

               Midioutshortmsg (…) ;  // ship straight out

               …..

               }

 

In probably thousands of hours of performance, there’s never once been a problem, but it would be good to do things ‘by the book’. I’ve tried to hunt down sample code but everything I’ve found is really simple and doesn’t illustrate my situation. Multithreading seems to be part of the solution, using real time signals such as events to trigger the output code. However, whatever approach is used needs to be fast, and my experience developing MT software suggests that could be a problem in the MIDI world where turnround times need to be ideally in the low milliseconds. Some of the Windows API synchronisation mechanisms also harbour significant overheads.

 

Could someone please point me to sample code that illustrates the correct approach?

               


bv

Viewing all 15302 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>