I've managed to solve my problem yesterday. I can't really tell what it really was, but it seem to me like a page size problem. Library had a page size increased to 64 since it was too large. I have created three libraries out of this one and left efault page size (16). Now it links juzt fine. Since I created new project, I'm not quite sure if something else didn't get involved, but perhaps it really was the page size. So in cae anybody runs into similar problem this may be the hint. Thanks for help. [ CoY0te ] Coyotus incrediblus...
CoY0te
Posts
-
C library and C++ application -
Help For Memory Leak ?The following call redirects standard output to a file:
freopen( "log.txt", "w", stdout );
Hope it helps. [ CoY0te ] coyotus incrediblus... -
C library and C++ applicationHi there! My project looks like this: #1 - libiupwin.lib - library written completely in C #2 - app.exe - application written in C++ - depends on libiupwin.lib The problem: I can compile #1, and a .lib file is generated I can compile #2, but linker fails with plenty of messages like: Unresolved external '_iupDlgNext' referenced from (...)\libiupwin.lib|itraverse "itraverse" is one of C files included in library, and iupDlgNext is of course a function (placed in library, too). I found one instance of 'iupDlgNext' and one instance of '_iupDlgNext' in a .lib file (using a text search). I guess this has something to do with differences between C and C++ function calls, but since I have little experience with "linking problems" I could use some help with this one. Thanks in advance. [ CoY0te ] Coyotus incrediblus...
-
function templateNo HTML tags this time. The code again: #define NEW(t) (t)*New(__FILE__,__LINE__) template T* New(char * File,int Line) { T* Pointer=NULL; Pointer=(T*)new T; ..... ) Hoping for any help... [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
-
function templateI'm experimenting with debug tool to report memory leaks. The idea is to create substitute for new and delete operators. I'm using a template function New, and a macro NEW (different for debug and release). Example below:
#ifdef _DEBUG #define NEW(t) (t)*New(__FILE__,__LINE__) #endif //#ifdef _DEBUG template T* New(char * File,int Line) { T* Pointer=NULL; Pointer=(T*)new T; ... other code ... }
This works perfectly for calls like:int * a = NEW(int); int * b = NEW(int[10]);
But the problem is dynamic size of arrays. In this case compiler cannot create template function for types not known at compile-time. So call like this one will not work:int a = 10; int * b = NEW(int[a]);
The error (in VC++ 6.0) is: error C2540: non-constant expression as array bound Any ideas of redefining the macro or the function to accept array size as a separate argument? [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke. -
LNK4084 - Simply unbelievable ;)Nothing that should have anything to do with the image size. I can't really tell when this warning message occured for the first time. Right now the application is working again but I still get this message. I did some changes in code, and then i've reconstructed one loop. Finally the code is almost the same as it was but somehow it works. At one moment it was just just a matter of 4 calls to glVertex (OpenGL;) between glBegin(GL_QUADS) and glEnd(). These calls used no arrays - they used immediate arguments, but adding them caused the crash - unbeleivable. I'm really getting sure it was it is a compiler or linker bug or something. I have solved the problem (temporally) but still heven't found the real reason. Thanks for your help. [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
-
LNK4084 - Simply unbelievable ;)I have a few static arrays used for temporary implementations, but total size of these arrays would be about 2-3MB, and I haven't added any recently (in fact I removed one). I think this is not it. Perhaps some VC++ bug. There are some (a "stepped" into some of them myself). Thanks anyway. Cheers. [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
-
LNK4084 - Simply unbelievable ;)Houston, I have a problem. I'm working on an application recently and I have made some really little changes in the code. Now it's not working anymore. I was trying almost everything. Environment: Visual C++ 6.0 + service pack Output message: warning LNK4084: total image size 277245952 exceeds max (268435456); image may not run MSDN says: The application exceeds the limit of 256 megabytes. In fact the application has only 143 kilobytes and uses some DLL's giving totally 556KB. Does anyone met such a problem? Greetings and thanks in advance. [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
-
Spawning another applicationI'll keep that in mind. These functions might be useful, allthough they do not allow You to specify the work directory for an application. Thank You. [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
-
Spawning another applicationThank You. Easy as 1..2..3 :) [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
-
Spawning another applicationPretty simple - I use:
ShellExecute()
to spawn another application. I use this function because it allows me to specify the directory for spawned application. Now I need to wait for the application to terminate (In fact i would like to spawn it in synchronous mode because I just want to spawn it and wait for it's termination. Is there any function that allows me to check if the application is still running using theHINSTANCE
returned byShellExecute
? Or perhaps there is another, easy way to spawn an application in synchronous mode, that does not need any loops checking application's state? (that will eliminate senseless processor usage). Thanks in advance for any suggestions. [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke. -
CString Format methodYo've missed one little thing: You have:
"%%.%f"
, and You should have"%%.%df"
And of course signif must be an integer value;"%%.%f"
tries to interpret your signif as floating poin value and it doez not produce the f char for m_nMorality."%%.%df"
will produce"%.f"
[ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke. -
CBitmap vs. HBITMAPI have solved that problem by coding my conversion this way:
CDC * pdc; CBitmap * OldBitmap; pdc=new CDC; pdc->CreateCompatibleDC(NULL); OldBitmap=pdc->SelectObject(Target); //this part of code is looped pdc->GetPixel(Point) ... //Color conversion ... pdc->SetPixelV(Point,Color) pdc->SelectObject(OldBitmap); pdc->DeleteDC(); delete pdc;
It works allright, but only because these images are small (9x15). Using GetPixel / SetPixelV is kinda slow i guess. It would be better to have a direct access to 24bpp image, but I haven't figured out how to load a resource into CBitmap object as 24bpp image every time. If someone has any better idea to do it faster without writting a bunch of code, then let me know please. Greetings. [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke. -
CBitmap vs. HBITMAPHow to ensure that CBitmap object will be created with 24bpp and it will stay that way when I use LoadBitmap? In typical API I would use the CreateDIBSection to create a 24bpp bitmap and I could freely access it's bits. But there is no such function in MFC. Do I have to use these API functions, or is there any "nice" way to do that with MFC classes? Some additional information: My code goes like this:
CPoint Point; CBitmap Bitmap; Bitmap.LoadBitmap(IDB_BITMAP);
Then I use my own function that converts colors in 24bpp images:ConvertBitmapColors(Bitmap);
And I draw it on the screen;dc.DrawState(Point,Bitmap.GetBitmapDimension(),&Bitmap,DST_BITMAP | DSS_NORMAL);
(dc is of course a CPaintDC object) Finally:Bitmap.DeleteObject();
The IDB_BITMAP resource is 24bpp bitmap, but the Bitmap object loads it with current desktop's color depth. I need some way to have an 24bpp bitmap, cause I want to make that color conversion before I draw it. [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke. -
Thread funcThanks - looks really nice indeed.:-D Anyway, I don't need any serious thread managment at this time, and I don't store the thread handle at all. I just have to run it and wait till it finishes the job, but I don't have to wait till process it really quits. All I care is when the data will be ready. ;) [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
-
Thread funcThank you for an advise. Using static function was the key problem. Now it works fine. By the way - what kind of runtime problems may occur when using CreateThread? I've been using this one many times, and never had problems with managing threads. [ CoY0te ] Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
-
Thread funcI want to use CreateThread() function, and i have created a ThreadFunc. The problem is, that i want this ThreadFunc to be placed within a calss (i don't want it to be a global function). member function is defined as follows:
unsigned long __stdcall ThreadFunc(void * Parameter);
And i try to do a conversion to:LPTHREAD_START_ROUTINE TS;
Both:TS=ThreadFunc;
And:TS=CMyDialog::ThreadFunc;
Report as follows: error C2440: '=' : cannot convert from 'unsigned long (__stdcall CMyDialog::*)(void *)' to 'unsigned long (__stdcall *)(void *)' First conversion works when ThreadFunc is not a class member, but both fails when it is a class member. How to make this conversion? Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke. -
CLOCKS_PER_SECIt's defined in Time.h and it's value is 1000. By the way - using windows timer is sometimes not enough. Although CLOCKS_PER_SEC is 1000, the timer is updated approximately every 55ms, that is less than 20 times per second. As for me i prefer to use QueryPerformanceCounter and QueryPerformanceFrequency functions - these use a timer that is updated very often (depends on hardware). I should be "smoother" than 1us (over 1MHz frequency). Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
-
Randomic functions ?Almost... The problem is: int rand(void); so it should be: rand()*n/RAND_MAX or ((double)rand()/RAND_MAX)*n Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
-
MDIGetActive() - always fails (!?!)Any attempt to call MDIGetActive() in my CMDIFrameWnd derieved class fails (program crashes, no asserts reported). Some details: -app created with MFC app wizard (MDI application) -I launch the application, press Ctrl+N to create a single MDI Child window and then select an option from menu that opens a dialog window. -this dialog needs some data from active MDI child so i call GetProblemData member function from CMainFrame class. -GetProblem data member function crashes when it calls MDIGetActive() (although at least one child frame is opened) -No other actions are taken at that moment, just placing a simple call to MDIGetActive() fails. Any ideas? Thanks in advance. Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.