|
We are preparing to upgrade our C/C++ apps from Visual Studio 6.0 to VS 2005. We have heard that VS 2005 no longer supports the standard C language calls (memcpy, memcmp, strcpy, etc) that we use frequently in most of our source code, and have used since back in the 1980's. Does anyone know if VS 2005 no longer allows these function calls directly?
Thanks, Mike
|
|
|
|
|
|
However, they are not actually deprecated according to the C++0x standard.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Those functions are fine -- they'll generate warnings.
The warning states what the 'better function' is and also how to disable the warning...
Before you decide though, you really should do a test compile under VS2005 to determine what other issues you might run into.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
I posted this in the VS forum, but I guess its more specific to C++...
I'm using VS.NET 2005 and building a large application with about 100 projects.
There is one project in the solution that compiles to a DLL that I need to debug. (i.e. break, and step into the code) However I can't. In the modules tab of the IDE, it says that no symbols have been loaded for that module. I know the pdb is being generated though, has the same filename as my dll, and is being generated in the same directory as the dll. The timestamps match as well, and I'm building the debug configuration.
When I right click on the module in the modules tab and goto "Load Symbols" and point it to my pdb it says that "The symbol file xyz.pdb does not match the module"
What could possibly be going wrong?
|
|
|
|
|
It is possible that the pdb is stripped of its symbols. This is done in deployment to lessen the install footprint. It is also possible that the pdb is not generated from the code that generated the dll.
Pax Domini sit semper vobiscum
|
|
|
|
|
I found the problem,
I had the VTune plugin installed in my VS install, when I removed it, I was able to debug ok. My guess is that the VTune plugin somehow messed up the pdb generation.
|
|
|
|
|
I'm trying to save a file to a fixed location. The would like file to be saved in the same folder as the executable, so I am using a relative path. However, I get mixed results. Sometimes it saves to the proper folder, sometimes to desktop, and sometimes to C:\.
If I use an absolute path, the problem goes away. So my question is whether the path specified when opening the file is required to be absolute? And if so, how can I get an absolute path from a relative path not knowing where the executable will be installed?
Here is my code:
CStdioFile LcfIniFile;
CString LcsTempStr;
if (LcfIniFile.Open("test.ini", CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite | CFile::typeText | CFile::shareDenyWrite))
{
...
LcfIniFile.WriteString(LcsTempStr);
LcfIniFile.Close();
}
Thanks.
Edit: MSDN says path can be relative, absolute, or network name. So now I really don't know what I'm doing wrong.
Edit2: I should also note that reading the file using the relative path did not cause any problems, it was only during write.
-- modified at 15:49 Wednesday 24th October, 2007
|
|
|
|
|
I think it all depends on what the current directory is.
And that all depends on how you run it....
Why not construct an explicit path to the file -- that way you can be sure.
use GetModuleFileName to determine the path of the exe...
split off the name and add "test.ini"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
How do I terminate my CWinThread from my main UI thread -- without blocking anything.
I was thinking I'd try something like:
PostThreadMessage( WM_QUIT, 0, 0 );
MSG msg;
while( PeekMessage(&msg, NULL, 0,0, PM_REMOVE ) )
{
if ( WaitForSingleObject(m_hThread,0) == WAIT_OBJECT_0 )
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
But that doesn't seem to work...
Any suggestions?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
or what about:
if I set m_bAutoDelete to FALSE
and:
PostThreadMessage( WM_QUIT, 0, 0 );
while ( PumpMessage() )
{
if ( WaitForSingleObject(m_hThread,0) == WAIT_OBJECT_0 )
break;
}
delete this;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
An example:
In your class which creates the thread:
private:
HANDLE m_StopThread;
HANDLE m_WaitThread;
static UINT ThreadFunction(LPVOID pvParam);
When you create your thread:
// Create events
m_StopThread = CreateEvent(0, TRUE, FALSE, 0);
m_WaitThread = CreateEvent(0, TRUE, FALSE, 0);
// Start thread
AfxBeginThread(ThreadFunction, this);
When you want to terminate the thread:
// Trigger thread to stop
::SetEvent(m_StopThread);
// Wait until thread finished
::WaitForSingleObject(m_WaitThread, INFINITE);
// Close handles
::CloseHandle(m_StopThread);
::CloseHandle(m_WaitThread);
//Your thread procedure
UINT CFoo::ThreadFunction(LPVOID* pvParam)
{
CFoo *pParent = static_cast<cfoo*>(pvParam);
while(true)
{
// Check event for stop thread
if(::WaitForSingleObject(pParent->m_StopThread, 0) == WAIT_OBJECT_0)
{
// Set event
::SetEvent(pParent->m_WaitThread);
return 0;
}
// Do your processing
}
}
Hope this helps you out!
|
|
|
|
|
That will only work if the thread has a message pump - i.e. is created as a UI thread. If it is a worker thread, I usually do the following (error checking removed for the sake of brevity):
in the main UI thread:
m_hTermEvent = CreateEvent (NULL, TRUE, FALSE, NULL);
m_pThread = AfxBeginThread (ThreadFunction, &m_hTermEvent);
SetEvent (m_hTermEvent);
WaitForSingleObject (m_pThread->m_hThread, INFINITE);
in the worker thread:
UINT __cdecl ThreadFunction( LPVOID pParam )
{
HANDLE hEvent;
hEvent = *((HANDLE *) pParam);
while (true)
{
if WaitForSingleObject (hEvent, 0) == WAIT_OBJECT_0)
break;
};
return 0;
}
Judy
|
|
|
|
|
That is NOT the case. This works as it should for worker threads!
Please, show me what in my code would not work!
|
|
|
|
|
pierre_ribery wrote: That is NOT the case. This works as it should for worker threads!
Please, show me what in my code would not work!
Calm down dude. No need to get snippy. I wasn't responding to your post, I was responding to the original poster. The presence of my post does not imply that yours is wrong. If you'll check the time stamp, we were posting at the same time. Your post didn't exist when I started mine.
Judy
|
|
|
|
|
Maybe I should go back to basic threading.
CWinThread is a UI thread in this case -- and has a message pump.
It seems that if I wait for it to terminate, then I am blocking my UI thread.
So, it seems I need to pump messages while I wait.
Or, do I have no clue?
More likely, I am just making this harder than it needs to be.
But, the goal is to wait for this thing to terminate completely.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Are you terminating a UI thread from within itself as you're showing
in your code or do you want to terminate a thread from another
thread and wait?
For the latter, maybe something like this:
OtherCWinThread.PostThreadMessage(WM_QUIT, 0, 0);
while (1)
{
DWORD dwWaitRet = ::MsgWaitForMultipleObjects(1, &OtherCWinThread.m_hThread, FALSE, INFINITE, QS_ALLEVENTS);
if (dwWaitRet != WAIT_OBJECT_0 + 1)
break;
MSG msg;
while ( ::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
AfxGetApp()-> PumpMessage();
}
}
mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you! -- I knew someone would understand the question!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
ah! insight!
I never quite made the distinction.
Thanks!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Attached below is the program... but it fails to execute!!
When i tried to execute: Cimg0Exception window pop up with the msg: CImg<unsined char="">::load_other():Failed to open image 'piggy.jpg". Check you have either the ImageMagick or GraphicsMagick package installed.
How do i install??(mine is Windows XP)
#include "CImg.h"
using namespace cimg_library;
int main() {
CImg<unsigned char=""> image("piggy.jpg"), visu(500,400,1,3,0);
const unsigned char red[] = { 255,0,0 }, green[] = { 0,255,0 }, blue[] = { 0,0,255 };
image.blur(2.5);
CImgDisplay main_disp(image,"Click a point"), draw_disp(visu,"Intensity profile");
while (!main_disp.is_closed && !draw_disp.is_closed) {
main_disp.wait();
if (main_disp.button && main_disp.mouse_y>=0) {
const int y = main_disp.mouse_y;
visu.fill(0).draw_graph(image.get_crop(0,y,0,0,image.dimx()-1,y,0,0),red,0,256,0);
visu.draw_graph(image.get_crop(0,y,0,1,image.dimx()-1,y,0,1),green,0,256,0);
visu.draw_graph(image.get_crop(0,y,0,2,image.dimx()-1,y,0,2),blue,0,256,0).display(draw_disp);
}
}
return 0;
}
|
|
|
|
|
purplee85 wrote: How do i install??(mine is Windows XP)
Please don't repost your questions. You can modify your original post to add the code. Of course in this case the code is irrelevant since you already told us you don't know how to install the library.
|
|
|
|
|
purplee85 wrote: CImg image("piggy.jpg"), visu(500,400,1,3,0);
Is it an absolute vs. relative path issue?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
purplee85 wrote: "Failed to open image 'piggy.jpg". Check you have either the ImageMagick or GraphicsMagick package installed."
How do i install??(mine is Windows XP)
Which part of
The Windows version of ImageMagick is self-installing. Simply click on the appropriate version below
and it will launch itself and ask you a few installation questions. is it you need help with?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hi.
I'm developing a library, and a function must display a form window with some controls. This form must be created based in a specification already written in some kind of file. I though in XML.
My question is, there is something already written that handle this kind of stuff? or I should start to warm my fingers and parse the XML file by my self?
Thank you and kind regards.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
We are in the process of converting the Database of a, very large and process intensive, 14 yr old C++ MFC (V6) app from using MFC/DAO and MSJet to MS SQL Server. We want to do this in a way that will not loose any perfromance. In addition after this interim release is completed we will be re-writing and migrating the whole thing to .NET using a combination of C#/Managed C++.
My question is... What is the best way of accessing the SQL Db that has the best performance and will not set back development time too much and will also allow the data classes to be easily migrated to .NET. Should we use ADO, OLE DB etc ? I've heard ADO has performance issues and OLE DB is difficult to work with. I've looked into "Express OLE DB" but the download links to Sypram all seem to be broken and all email to the company is bouncing back.
Any suggestions would be appreciated.
Thanks
Steve Jacovino
ConEst Software Systems
|
|
|
|
|