Wednesday, 24 August 2011

C++ CListCtrl Image List disapear on click FIX

To fix this problem with the icon vanishing change ILC_COLOR32  to ILC_COLOR24
e.g.
 m_ImageList=new CImageList();
 m_ImageList->Create(32,32,ILC_COLOR24,0,3);
 hIcon1 = hIcon1=AfxGetApp()->LoadIcon(IDI_ICON_CUSTOM_PAL_COLOR);
 c1 = m_ImageList->Add(hIcon1);
 hIcon2=AfxGetApp()->LoadIcon(IDI_ICON_CUSTOM_PAL_GREY);
 c2 = m_ImageList->Add(hIcon2);
 hIcon3=AfxGetApp()->LoadIcon(IDI_ICON_CUSTOM_PAL_MONO);
 c3 = m_ImageList->Add(hIcon3);

Wednesday, 10 August 2011

workaround for C++ clock_gettime gettimeofday tv_usec tv_nsec make rand() srand() MAC OSX Lion / Intel fix

Instead of using gettimeofday or clock_gettime use below:-

#include <mach/mach_time.h>
#include <mach/mach.h>
#include <mach/clock.h>

// OS X does not have clock_gettime, use clock_get_time
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
ts.tv_sec = mts.tv_sec;
ts.tv_nsec = mts.tv_nsec;

// make unique
srand( (unsigned)time( NULL ) + ts.tv_nsec);
long random = rand()+ ts.tv_nsec

Thursday, 4 August 2011

c++ 'unresolved external symbol __security_cookie '

Long story short, the cause of this error is that /GS switch is a default switch in the compiler shipped with the PSDK.

To fix this problem you need to link your code to bufferoverflowU.lib. This should do it for most of applications out of there.

Just do

cl.exe a.cpp bufferoverflowU.lib

or

link a.obj bufferoverflowU.lib