|
don't use C++ code in .C files, and don't #include headers that use C++ code in .C files.
the compiler compiles .C files as C and that means any C++ code it sees while compiling a .C file is just syntax errors.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
prgr wrote:
Can anyone gimme an idea,how to deal with this?
You need to use extern to Specify Linkage[^]
Here's an example:
#ifdef __cplusplus
extern "C" {
#endif
int c_func_in_c_file(int someParm);
int c_func_in_c_file2();
#ifdef __cplusplus
}
#endif
#include "cFunctions.h"
#include "cppFunctions.h"
int c_func_in_c_file(int someParm)
{
return someParm + c_func_in_cpp_file();
}
int c_func_in_c_file2()
{
return 42;
}
#ifdef __cplusplus
extern "C"
{
#endif
int c_func_in_cpp_file();
#ifdef __cplusplus
}
int cpp_func_in_cpp_file();
#endif
#include "cppFunctions.h"
#include "cFunctions.h"
extern "C" int c_func_in_cpp_file()
{
return cpp_func_in_cpp_file() + c_func_in_c_file2();
}
int cpp_func_in_cpp_file()
{
return c_func_in_c_file2();
}
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I have to read and store data in a series of unsigned short variables in Shared Memory.
Now these variables are scaled and I need to convert them into their proper units. I display them as either float or integers.
For example for one variable:-
Max Val = 0.999969
Min Val = -1.000000
Least Sig Bit = 0.000030517578 = scaleFactor1.
So what I do is:-
unsigned short currentField = *(unsigned short *) fieldPtr;
float scaleFactor1 = (float)GetScalingFactor(scaleFactorStr);
float rescaledDataEng = currentField * scaleFactor1;
This works OK (rescaledDataEng ) for positive numbers, but for negative numbers it fails, e.g. I get for -0.44 the incorrect value displayed as (rescaledDataEng = 1.560028).
Are they a neat soultion to this problem other than adjusting for out of range data.
if(rescaledDataEng > maxValue) rescaledDataEng = -(1 -(rescaledDataEng - maxValue)); Also I dont think that I store the data (negative value corectly) when writing to the Sared Memory:-
*(unsigned short *) fieldPtr = (unsigned short)(fEngValue/m_fScalingFactor);
For example for one variable:-
Max Val = 179.999
Min Val = -180.000
Least Sig Bit = 0.005493 = m_fScalingFactor.
I enter -20 and 159.01 is displayed.
Any suggestions please as the more I look at the problem the more confused I get.
|
|
|
|
|
How can you read in negative values into an unsigned variable? e.g.
unsigned short currentField = *(unsigned short *) fieldPtr;
You can never have currentField = -0.44 or -20 and have correct results.
|
|
|
|
|
This may help to show the problem:-
For example for one variable:-
Max Val = 179.999
Min Val = -180.000
Least Sig Bit = 0.005493 = m_fScalingFactor.
I enter 20 and 20.00 is displayed; i.e. 20/0.005493 = 3640.9976 is stored
(0E38 Hex)
When I come to display the value I do the following:-
Get the value (0E38) and re-scale it = 0E38 * m_fScalingFactor = 20.00.
Works fine!
But for this example:-
Max Val = 179.999
Min Val = -180.000
Least Sig Bit = 0.005493 = m_fScalingFactor.
I enter -20 and 159.01 is displayed.
How to handle negative numbers?!?
grahamfff
|
|
|
|
|
Additionally, you can use below formula to scale any value from one range to another:
a = (q - p)/(s - r)*(b - r) + p
if you'd like to convert value of b belonging to range (r,s) to value a belonging to range (p,q).
|
|
|
|
|
will this equation cope with signed and unsigned data; e.g. could have a counter defined as unsigned with range 0 to 65534 with LSB = 64.
Also have angle, signed range -1 tp +1 with LSB = 0.0055
(Range -180 to +180 degrees)
Cheers,
Graham.
grahamfff
|
|
|
|
|
The formula I gave is the most appropriate for floating point arithmetic. It does work in all cases where you have to scale one set of values from an interval to another interval. In the case of integer values there is a matter of precision loss but at some level of accuracy it works as well. LSB converts from t (old) to v (new) as follows:
v=((q-p)/(s-r))*t
PS. If I understood you well...
|
|
|
|
|
hi
i want to create chatting applicatoin for LAN for that i m using the CAsyncsocket class. i had searched the MSDN for that purpose.
i made the client and server from the help of MSDN but i works on the single computer but not on lan.
The steps specified in the MSDN for making the server is
create (portno);
listen( );
accept();
but the server is not binded with any adress. what i should do use the bind ( ) function or give these paramter on create ( ).
there is no description what is the default values are.
can anybody help me and give the names of functions for making the Lan server and client with paramete bcos no decription what are defaul
and what not.
ddd
|
|
|
|
|
|
Why don't you trace the code to find out what CAsyncSocket::Create does?
This is the easiest way of learning MFC .
Don't try it, just do it!
|
|
|
|
|
I need a good and smart way to pick a number and then make it "occupied". This is needed on 9 lines with 9 numbers from 1-9. I have a system allready with a class that makes a bool true when its occupied but there's some leak=/ because it's looped and must be applied on every line.
Does someone have a good general way to do this?
I'm trying to make a solver for this puzzle.
http://www.puzzle.jp/letsplay/applet/sd_sample_002-e.html[^]
|
|
|
|
|
One way might be:
int nNumbers[9][9] = {0};
...
while (1)
{
int nRow = rand() % 9;
int nCol = rand() % 9;
if (0 == nNumbers[nRow][nCol])
{
nNumbers[nRow][nCol] = 1;
break;
}
} There are several other approaches to this.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanks for answering but it's not really what I'm looking for.
You see, I have a class called Number.
I create a [9][9] array of it.
It is preset with 1-9 for every line:
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
myNumbers[i][j].setNumber(j + 1);
}
}
It is suppose to return a value:
//The puzzlecell is a class too.
//The random picked number for the line is put at the current position in the PuzzleCell which stores a value and will be presented in a Label when done.
myPuzzleCell[i][j].setTheValue(myNumbers[i][tempRand1].getNumber());
All this has to have the ability to preset and reset stuffs since I have all this in a huge loop which checks if the lines are good due to the Puzzle rules, which you can find at the page I linked previously. Please check the puzzle out so you get a hint.
Notice that I cannot only set random values and wish for it to be done in a century, I also have a system where I if a Line == 45 // (1+2+3+4+5+6+7+8+9) then save that line (by setting them to permanent true).
|
|
|
|
|
can any one tell me how to display a web page using MFC? just like we do in VB making use of the web controls...
regards,
Rookie
|
|
|
|
|
One way is to create an SDI application using a view derived from CHtmlView . Then you can use the Navigate() or Navigate2() methods to display the page.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Another way is to directly use a web browser control. See this[^] link.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Nice link Ravi.. thanks.. i cant believe how fast i'm getting help with codeproject..!
vivek
|
|
|
|
|
thanks david n ravi. the link is really resourceful.
learning,
Rookie
|
|
|
|
|
i just had similar doubt.. thankz rook
vivek
|
|
|
|
|
hi ppl,
I've been looking around for a while now, and I still can't find a simple, minimum & easy to use RSA implementation (and free of course). If know of such implementation, I'd appreciate some info
I need to be able to use the implementation in a shareware app, but only for my protection scheme, i.e. internal use. Further on, MFC or any other framework should not be used (so, plain Win32 API or STL are good )
I know this is a bit too specific, but if anyone knows anything, it would be a great help
---
YOU KNOW WHAT YOU ARE BLONDIE!?!? YOU'RE JUST A SON OF A BA A A A AAAAAAAAAA!!!!!
http://sprdsoft.cmar-net.org
http://t1tan.cjb.net
|
|
|
|
|
|
There is also a version from RSA laboratories... It is much smaller and easier to use... but I've forgotten the download link
Don't try it, just do it!
|
|
|
|
|
I've been digging through RSA labs site for a loooong time, and all I could find is a bunch of docs Is there another download location for RSA stuff??
thx
---
YOU KNOW WHAT YOU ARE BLONDIE!?!? YOU'RE JUST A SON OF A BA A A A AAAAAAAAAA!!!!!
http://sprdsoft.cmar-net.org
http://t1tan.cjb.net
|
|
|
|
|
yeeeees I've tried that, I couldn't get the thing working..
Anyways, since RSA is going to be a part of anti-crack-hack-slash protection, I think it would be unwise to use crypto++ since it's a separate module..could be easily avoided & my proggy would eventually get hacked (like that's not gonna happen anyway )
But I might take a closer look whatsoever, thanx
---
YOU KNOW WHAT YOU ARE BLONDIE!?!? YOU'RE JUST A SON OF A BA A A A AAAAAAAAAA!!!!!
http://sprdsoft.cmar-net.org
http://t1tan.cjb.net
|
|
|
|