|
|
Hi,
I just ended a debate with someone and this was the topic:
When an application (hw.cpp) is compiled with a library (library.lib) does the resulting executable contain the entire library.lib or does it just contain the functionality (the code) it needed from the library and, of course, hw.cpp.
Personally, I'm positive it only contains the code it needed from the lib - not the entire lib.
Thanks.
|
|
|
|
|
you're right. the linker will pull in only what the app needs.
that is, without getting into a discussion of 'compilation units' and other arcana, the linker, on the whole, doesn't pull in things you don't use.
-- modified at 11:58 Wednesday 6th December, 2006
|
|
|
|
|
Thanks Chris, you've helped me out before, too.
Thanks again!!
C
|
|
|
|
|
I need to use function byte*strcat(byte*, const byte*)in following
strcat(byte* dest, ":");
I receive following warning:
warning C4133: 'function' : incompatible types - from 'char [2]' to 'const byte *'
How to resolve this problem?
|
|
|
|
|
how's defined your type byte ?
have you tried to explicitely cast to (char*) and (const char*) respectedly ?
moreover, what doest that mean : strcat(byte* dest, ":");
is it how you call your function ???
oh, and at last, it is a warning, not an error, so, nothing blocking !
|
|
|
|
|
lose the 'byte *'.
Calls should not contain thier datatype unless you are specifically casting it to that type and then you need to wrap the data type in parenthesis or angle brackets.
such that,
strcat(byte* dest, ":");
becomes,
strcat((byte*) dest, ":"); /*byte* is 'casted'*/
Otherwise, just plan ol' remove the byte* from your statement, resulting in:
strcat(dest, ":");
Ideally, you should ensure your datatypes are the same whereever possible.
|
|
|
|
|
I want to link txt files(help file) into EXE files.
Please give me some idea for this issue.
|
|
|
|
|
Add them as RT_RCDATA resource types.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Max++ wrote: want to link txt files(help file)
Out of curiosity, why not use HTMLHelp? It actually makes it easier to maintain.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
I've used MFC to create a custom control: An Ellipse with an edit control inside, so it appears as a circular edit box. Problem is, I can't get the data out from the edit control whenever I type anything in. I'm using the windows message handler WM_CHAR, but I fear that that message handler is only interested in the rectangle and not the edit control. How do I get access to the edit control's data?
Thanks
|
|
|
|
|
MyFathersSon wrote: Problem is, I can't get the data out from the edit control whenever I type anything in
Maybe these will help?
Three ways to get text from an edit control:
CEdit::GetWindowText()
EM_GETLINE message to edit control
WM_GETTEXT message to edit control
|
|
|
|
|
Cheers Mark, Unfortunately I feel that the code might be causing problems. I code the control as follows:
void CEditableCircleCtrl::DrawControl()//called by OnDraw method
{
CDC *pDC = GetDC();
if(pDC == NULL)
{
return;
}
CRect circlerect;
//draw the round rectangle
circlerect.top = 0;
circlerect.left = 0;
circlerect.bottom = 40;
circlerect.right = 40;
pDC->Ellipse(circlerect);
}
...
int CEditableCircleCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
//create the edit box
editrect.top = 13;
editrect.left = 6;
editrect.bottom = 28;
editrect.right = 36;
editctrl.Create(WS_VISIBLE|WS_CHILD|ES_CENTER,editrect, this, 0);
return 0;
}
How can I get hold of the text? Am I doing something wrong? WM_CHAR doesn't capture any text entered in the control. Where would I place any of your suggestions?
|
|
|
|
|
WM_CHAR would be sent to your editctrl object (which I assume is a CEdit(?)) so you'd need to
override CEdit and in your derived class handle WM_CHAR. That's if you really need to intercept
every char as it is entered by the user.
Anytime you want to extract the text from the edit control (after it is created, of course) you
can use something like
TCHAR szBuffer = new TCHAR[editctrl.GetWindowTextLength() + 1];
editctrl.GetWindowText(szBuffer, GetWindowTextLength() + 1); or
CString str;
editctrl.GetWindowText(str);
|
|
|
|
|
Cheers Mark, that was very helpful. Thanks for your time
|
|
|
|
|
Hie,
I have one function
void Log(const string& format="", ...)
{
va_list args;
va_start(args,format);
int len= vsprintf(buffer, format, args);
va_end(args);
cout<
|
|
|
|
|
vikrams wrote: vsprintf(buffer, format, args);
Maybe you are passing a invalid format string. If it's not a valid format string then the behavior is undefined.
Maybe you can modify the above function to look like this...
void __cdecl Log( const char* lpszString, ... )
{
va_list args;
va_start(args, lpszString );
int len = vsprintf(buffer, lpszString, args );
va_end(args);
}
And what is this buffer variable??
|
|
|
|
|
I tried using format.c_str().
but it's crashing.
|
|
|
|
|
please Vikrams you start to know CP well enough nowadays to know that you should post code samples within <pre></pre> html tags...
see my sig for a relevant link
|
|
|
|
|
To add to Nibu , uninitialized buffer could be causing crash.
Can you show , how it is declared ?
|
|
|
|
|
void Log(const string& format="", ...)
{
char buffer[1024]="";
va_list args;
va_start(args,format);
int len= vsprintf(buffer, format.c_str(), args);
va_end(args);
cout<<buffer;
}
This is not working !
|
|
|
|
|
This code runs without any crash.
|
|
|
|
|
vikrams wrote: This is not working !
With what input?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
vikrams wrote: This is not working !
When using a string type, va_start() adds 16 bytes to the starting address of format to get to the first optional argument. However, when using format.c_str() with vsprintf() , you are not 16 bytes from the start of format .
Try this instead:
void Log(const char *format, ...)
{
char buffer[1024] = "";
va_list args;
va_start(args, format);
int len= vsprintf(buffer, format, args);
va_end(args);
cout<<buffer<<endl;
}
...
Log(fmt.c_str(), "Hello World");
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'd use the Boost.Format[^] library to do this kind of thing.
Steve
|
|
|
|