|
Dear friends,
I have declared a structure variable in common.cpp and i want to use the structure members in one.cpp as well as two.cpp. When i include the common.h in those two files, i am getting the "LINKER ERROR" saying
"struct COMMSETTINGS commparam" (?commparam@@3UCOMMSETTINGS@@A) already defined in DLMSView.obj
Please help me in solving this problem
|
|
|
|
|
common.h:
struct COMMSETTINGS {
};
extern COMMSETTINGS commparam; common.cpp:
#include "Common.h"
COMMSETTINGS commparam; one.cpp and two.cpp:
#include "Common.h" Note the extern keyword used in common.h. This keyword, used in the declaration, tells the compiler/linker that the definition is found elsewhere. In this case, the definition is in common.cpp .
Software Zen: delete this;
|
|
|
|
|
Hi all:
I have a problem when I try to divide two floating point number to get a reasonable integer result. For example 1.0000 / 0.2000, this gives me 4 but not 5. Does anybody have any good idea to solve this problem please???
Many thanks
Asura
|
|
|
|
|
how do you do this ?
did you try using ::floor() and ::ceil() too ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
1.0000 / 0.2000 should give you 5. so the values must be a little different than you think.
In any case, one old trick is simply to add 0.5f to the result of the division. When you cast the result to an int if the original result was x.5 or greater the result will be x + 1 otherwise it will be x.
|
|
|
|
|
For negative numbers, you need to subtract 0.5f.
-0.7 + 0.5 = -0.2 => 0.0
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Stan has it right. The issue is that when converting from a real value to an int the compiler truncates the result. Here's something you can try :
int NearestInt( double value )
{
return (int)( value + 0.5 );
}
int NearestInt( float value )
{
return (int)( value + 0.5f );
}
-- modified at 13:37 Saturday 19th November, 2005
|
|
|
|
|
Testing VC++ code for pointer underflow/overflow for data type char *.
knarasimharao
|
|
|
|
|
I suppose you can check the index into the string, and the size of the string, which was allocated, so that the index should be less than the size, and always greater or equal to zero.
You can use:
AfxIsValidString(...)<br />
AfxIsValidAddress(...)
to check that the address is readable/writable.
this is this.
|
|
|
|
|
don't make the confusion : char* is not always a string !!!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
I want to add my own printer dialog setupt in the list of supported printer drivers , sort of virtual printer driver not doing actually printing , or simply i want to extend office printer dialog
|
|
|
|
|
Hi all,
I wanna write a program that can monitor and discover any change of file in windows sytem and notify the change to user. where should i begin and what should i read ?
Thanks,
ken
|
|
|
|
|
I think ReadDirectoryChangesW(...) should do.
It can watch a directory for changes.
There are a few resources (articles) here on CP that implement this function.
this is this.
|
|
|
|
|
|
Hi.I'm seeking for help on my recent project.Actually, i'm developing a program that embeds several network analysis tools into single program.That is, once the user clicks on button "Tool 1", the .exe file of the tool will be called and it will run the tool.The problem now is, i don't know how to link the button with the corresponding file.Please help me.
-- modified at 3:03 Saturday 19th November, 2005
|
|
|
|
|
In the Click event of the button, use:
ShellExecute(NULL,"open",path_to_exe_file,NULL,NULL,SW_SHOWNORMAL);
Just replace path_to_exe_file with the physical path of the other exe.
this is this.
|
|
|
|
|
Thanks.I'll try.
|
|
|
|
|
Hi,
I need info about the WaitThreadFunc. All I know now is the function prototype =>
unsigned int __stdcall WaitThreadFunc(void * _param);
How does this function work?
|
|
|
|
|
Looks like a callback function.
If it is, then you need to implement it yourself and give the its name to the function that uses it.
this is this.
|
|
|
|
|
Hi,
I've developed an application where i'm readng some data from a file before the main window is created ,so accordingly i've placed the code in a class derived from CWinApp.When i compile and run the program itz doing well and i'm getting the desired output,But the problem starts when i click the EXE icon in the debug folder .
Itz giving out an error that the specified file could not be opened.Then i used FormatMessage to see what the error was and it says "The System Cannot Find The File Specified".How do i rectify this error?.It would be really great if someone can help me out in this.Thanks in advance.
rajeev
|
|
|
|
|
The file you are trying to open is located someplace else. You need to use the exact physical path of the file. You can use:
char szPath[MAX_PATH];<br />
GetModuleFileName(NULL,szPath,MAX_PATH);
It will return the path of this exe like: "c:\asd\debug\asd.exe"
And parse the returned string to remove the characters after the last backslash. Then append the name of the file you want to open.
this is this.
|
|
|
|
|
Hello, everyone,
Who know the different between C Struct and C++ Struct?
Please tell me?
|
|
|
|
|
In C a structure is a colection of data items only.
In C++ a structure is the same as a class, accept that the default access is public instead of private.
INTP
Every thing is relative...
|
|
|
|
|
DEAR SIR
can you give a example
I donot understand your say
----------------------------
Jerry yu
Chinese
programming fans
我的QQ 290785513
中国人的加我
|
|
|
|