|
|
I don't think that will work because that stores it in a structure. I need it to be in one variable.
|
|
|
|
|
use an unsigned __int64, something like:
unsigned __int64 i64 = (unsigned long)longOne * ((unsigned long)-1) + longTwo;
ie.. the high 4 bytes are your first long and the low four are your 2nd long.
-c
All you have to do is tell the people they are being attacked, and denounce the opposition for lack of patriotism and exposing the country to danger.
-- Herman Goering, on how to control the public
|
|
|
|
|
How do i get the two longs back out of the unsigned__int64?
|
|
|
|
|
longOne = i64 / (unsigned long)-1;
longTwo = i64 - (longOne * (unsigned long)-1);
or something similar
-c
All you have to do is tell the people they are being attacked, and denounce the opposition for lack of patriotism and exposing the country to danger.
-- Herman Goering, on how to control the public
|
|
|
|
|
Gilfrog wrote:
I need it to be in one variable.
You may use __int64 if you want to play with shifting bits. But why can't you use a structure?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
A structure would solve the issue would it not?
#pragma pack(1)
typedef struct two_longs_dont_make_a_right
{
long one;
long erone;
} two_longs;
? Why in 'one' variable?
Ryan Baillargeon
Software Specialist
Fuel Cell Technologies Inc.
|
|
|
|
|
I need to save an Array of 2 shorts and long to a text file. I just figured it would be easier to save them in one variable that to seperate them with commas or something like that.
|
|
|
|
|
Why not use a structure in combination with a union, like so:
typedef struct tagTwoLongs
{
union
{
struct
{
long Long1;
long Long2;
};
__int64 OneVariable;
};
}TwoLongs;
Now you can refer to the two longs separately, via Long1 and Long2, or together, via OneVariable.
Chris Richardson
|
|
|
|
|
Make sure that the pack pragma is 4 or less for the union
technique to work. You might want to ensure this by temporarily
specifying the packing alignment:
<br />
#pragma pack(push,4)<br />
typedef struct tagTwoLongs<br />
{<br />
union<br />
{<br />
struct<br />
{<br />
long Long1;<br />
long Long2;<br />
};<br />
__int64 OneVariable;<br />
};<br />
}TwoLongs;<br />
#pragma pack(pop)
P.S. Is there a way to get a compile time
assertion that sizeof(long)==4?
|
|
|
|
|
Good call on the packing. I forgot about that.
Scott H. Settlemier wrote:
P.S. Is there a way to get a compile time
assertion that sizeof(long)==4?
Yeah, in winnt.h, there's a macro called C_ASSERT. Here's it's definition, and the comment that describes it:
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
Chris Richardson
|
|
|
|
|
ooh, nice. thanks. I've been wanting that ability
for a long time. I see they just sorta kludged
one up there. (neg index error. )
Too bad this wasn't added to the language.
|
|
|
|
|
thanks, that works for me.
|
|
|
|
|
You mean the Win32 LARGE_INTEGER structure defined in WinNT.h
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
I only replied to him an idea and a simple definition. I suppose I could have used (and would have used) LARGE_INTEGER as my example, but I didn't think of it at the time.
Chris Richardson
|
|
|
|
|
I need a sample project - how to handle with data (store/edit/delete) in any format - but without any additional actions (registering in ODBC, etc.) I want to have redistributable application, wich are need juct unpack, and have to work with data.
thank tou.
|
|
|
|
|
Can I put both of these on the same machine? Any known problems or conflicts?
thanks
ns
|
|
|
|
|
There have been a couple people here on CP that seems to be running both concurrently with no problems. I haven't tried it myself though.
Jeremy Falcon
Imputek
<nobr>"Oh no there was a knife in that kitchen drawer and I cut myself - please remove the kitchen." - David Wulff
|
|
|
|
|
Thank you. I just called MS and they said theres no problem....so I shall be brave and give it a try.
Appreciate your help,
ns
|
|
|
|
|
Rather yes. I'm using both IDEs for few months and everything works fine. I think that it will be better if you install VS6 before VS7.
greetings
|
|
|
|
|
Great! Now if I click on a vS6 dsw, what program will be launched? VS6? Or do I have to first start VS6, then load the VS6 project into it?
Appreciate your help,
ns
|
|
|
|
|
If you have installed VS6 before VS7 dsw file type (and of course all files connected with VS) will be connected with VS7, therefore VS7 will be launched, so you will have to load project manually in VS6.
greetings
|
|
|
|
|
Okay. makes eminent sense. Thanks
Appreciate your help,
ns
|
|
|
|
|
Hi,
I have a VC++ project;
I have a dll with several classes that I export (one of them is this one, with static members declared in a header file and initialized in it’s .cpp file), and I’m using them from another dll. For the other classes I had no troubles (I included the header files and used them normally) but I don’t know what happens with this one.
When I see the dll’s depends it’s all ok; I can see the class and its attributes, but when I try to use it from another dll (like className::attributeName ), at linking time, I got an ‘unresolved external symbol’ error, but it compiles well.
I’ve tried:
- Include the class header file with __declspec(dllimport) in the dll that uses it
At linking time returns ‘error LNK2001: unresolved external symbol’
- Make a header file with extern sentence ( extern string className::attributeName; );
At compiling time returns: file.h(53) : error C2720: [attributeName] : 'extern ' storage-class specifier illegal on members
- The same header file, but with extern “C” sentence
( extern “C” string className::attributeName )
At linking time return:
file.obj : warning LNK4006: "public: static class string className::attributeName already defined in file2.obj; second definition ignored
Can someone help me to resolve this?
Thanks
Paranoico? yo???
|
|
|
|
|
It should work - it does for me. I guess your second dll (the one which should import) is having problems with correct __declspec. Can you create small exe which links dynamically with dll exporting static members?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|