|
following is one function I coded before, I simplify it now, please have a look:
sz is definded as char sz[1000] bellow:
in real code, sizeof sz should be dynamically alloced.
in C++, params of a function are ordered in memory.
//---------- function
BOOL MyFormat(const char*pszFmt,...)
{
//align to sizeof(int) for args after pszFmt
const char*pszArg=(char*)&pszFmt+((sizeof(pszFmt)+sizeof(int)-1)&~(sizeof(int)-1));
int iBuf=_vsnprintf(sz,999,pszFmt,(char*)pszArg);
if((iBuf>=0)&&(iBuf<1000)) return 1;
sz[0]=0;
return 0;
}
//-----------------
I deleted too many lines, if it doesn't work, i will test again for u, above is an idea only - but I guess it works.
A special image tool for Windows C++ programmers, don't miss it!
The world unique Software Label Maker is waiting for you and me ...
A nice hyper tool for optimizing your Microsoft html-help contents.
-- modified at 4:05 Sunday 2nd April, 2006
|
|
|
|
|
Hey, I guess the address of the params in function are placed together,it's right? So I write this code and it works:
int fun(int x,...){
int *next = (int*)(&x+1);
cout<<*next<
|
|
|
|
|
Yes you can , the three ... after the second comma stands for elippse notation which means the function can take any number of params ,
fun(int ,int ,...);
This means the fun function will take a minimum of two args and if wanted can take any number of other types of args also .
Regards,
FarPointer
|
|
|
|
|
Look at the va_start() , va_arg() and va_end() macros.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
if u look at definitions of va_xxx()s, they are just about memory addresses of params.
A special image tool for Windows C++ programmers, don't miss it!
The world unique Software Label Maker is waiting for you and me ...
A nice hyper tool for optimizing your Microsoft html-help contents.
|
|
|
|
|
includeh10 wrote: if u look at definitions of va_xxx()s, they are just about memory addresses of params.
On some systems, but not on all. And the memory addresses are not the same on all systems. Use the macros - they're there for a reason.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Having read some material about toolbar part of MFC, I can't find how to implement the output window(the same as workspace window) in VC6.0, does it inherit from some CControlBar?I don't know how to add the triangle and close button beside it? does anybody know?
Thanks.
have a good day
|
|
|
|
|
WorkSpace Window and the output window are two different windows, the first one showing the class and file information and the second one showing the information regarddng the build,debug,find etc.
While Workspace window is implmented using property sheet ,and list controls .
Output Windows using a richedit control.
if you want more info u can use spy for it .
And i feel it should be derived from CDialogBar with the property sheets embedded in it .
Regards,
FarPointer
|
|
|
|
|
currently I have to convert it into the access 97 version. is there any way I can use it directly? e.g. is there any service pack or something like this?
Thank you very much!!!
-------------------
I am learning C++ and English
|
|
|
|
|
|
this is exactly what I am looking for!
Thank you very much!!!
-------------------
I am learning C++ and English
|
|
|
|
|
hey, working with winpcap and trying to create a dll, my source is working, except the compiler will not build my project because it is complaining about unreferenced identifiers, which are referenced in the wpcap.lib file. I added the lib to my files using project > add to project > files.. and that didn't work. I then tried adding the reference via ALt + F7 > link tab and that didn't work either. I am rather new to visual studio and am at a loss. What do I need to do to link the library to my project? thanks in advance.
nada
|
|
|
|
|
You do not add lib files to project, instead you have to add them to
project -> settings -> link tab. There should be something called additional libs. I don't remember what exactly it is called and I dont have vc 6.0.
-Saurabh
|
|
|
|
|
OK, I tried:
1. Project
2. Settings
3. Link Tab
4. Switched 'Category' to 'Input'
5. A Text field appeared with the name, 'Additional Library Path'
6. I typed the path: c:\mylibs
7. OK
Doesn't work. Repeat steps 1 - 6, but included the name of the lib with path. Clicked OK, and still not working.
Does it matter that I am writing a dll, because the lib works in the exe I wrote but not in the dll project. I didn't create the initial exe project, so I don't know how it was linked, I simply built off the example.
Anymore help, anyone? thanks in advance.
|
|
|
|
|
|
I've just recently tried that as well, however, that did not work either. I ahve no idea why not. I figure if I specfied the directory the lib is in and include it in the list, I should be able to use it in my project --that is not the case.
I absolutley NEED this lib to link up, otherwise my code is completly functionless. What else should I be doing? I looked at my exe project: the one that the lib is currently linked and working --I saw no reference to the lib in links. Instead, the lib was listed amongst the source, def, header, etc.. files. I have no idea how it was linked.
I am currently learning how to write dlls, and it would be a great help to get this working, so thank you thus far, any more ideas, and thanks in advance.
|
|
|
|
|
try #pragma comment(lib,_T("yourlibaray name"))
|
|
|
|
|
I put that in stdafx.h, right? Well, I tried it there and it said:
[quote]
Line (13) : warning C4083: expected 'string'; found identifier '_T'
[/quote]
...then I tried it in the main source file and it said the same. I have seen that suggested in other forums, do I need to put the path as well or just the name? Do I still need to add the references to the lib in the link tab or no? BTW, since I have read to use the pragma thing, I have tried it this way:
[quote]
#pragma comment( lib, "wpcap.lib")
[/quote]
...and that did not work as well. I thought the added _T() thing would be the solution. thanks anyway.. any more ideas from anyone? thanks
|
|
|
|
|
borono wrote: #pragma comment( lib, "wpcap.lib")
What is the exact error when you try using this? Can you copy and paste the output from the bottom of MSVC.
|
|
|
|
|
sure, here it is:
--------------------Configuration: test - Win32 Release--------------------
Compiling...
test.cpp
C:\test.cpp(24) : error C2065: 'pcap_findalldevs_ex' : undeclared identifier
C:\test.cpp(24) : error C2065: 'PCAP_SRC_IF_STRING' : undeclared identifier
Error executing cl.exe.
test.dll - 2 error(s), 0 warning(s)
thanks in advance
|
|
|
|
|
This is not a lib error, this error means you are trying to use a function which the compiler cannot find. Did you include the header file for winpcap
#include <pcap.h>
-- modified at 0:42 Sunday 2nd April, 2006
|
|
|
|
|
yes. I added it to the project via project > add to project > files... then in code as you have above. I looked in the header and the pcap_findalldevs_ex identifier is not listed, only pcap_findalldevs is, and neither is PCAP_SRC_IF_STRING.. those are identified in the wpcap.lib file. That is why I assumed the lib was not linked properly. I have the associated .dll for the lib, so it should work if linked properly, I assume. I must have screwed something up in the transition. It has to be in the way I am linking the header or lib. Assuming the header is present, the lib is linked via the links tab, what else could be the problem and/or possible soultion? I appreciate the help guys. thanks
|
|
|
|
|
borono wrote: those are identified in the wpcap.lib file
A defined function is only a function name, these will be in your header files and they tell the compiler that there is a function of that type, the linker then tries to find it.
A declared function is a function and all of it's code, this would be in a source file, or in your case a lib file.
The problem you are having is that the compiler doesn't know that the function exists.
Add this line directly before you include pcap.h #define HAVE_REMOTE
and let me know.
-- modified at 1:09 Sunday 2nd April, 2006
Another note, you can't find them in the header file because you are looking in the wrong one. Take a look in the remote-ext.h header file
|
|
|
|
|
I dont know if I did the equivalent. I did this and it compiled with no errors, just a minute ago.
1. Project
2. Settings
3. C/C++ tab
4. Change Settings For to All Configurations
5. Preprocessor Defintions add: HAVE_REMOTE
6. OK
I now have to figure out why the dll when called is crashing the app. At least I can start working on the code again, that was rather annoying to deal with, indeed. I will try to do it your way to see if that makes a difference at run time. I appreciate the help a lot, I might come back once I get a handle on this dll and actually start coding something. I will most likely have questions. haha
Anyway, I guess this is solved. Thanks again
best regards
|
|
|
|
|
borono wrote: I dont know if I did the equivalent.
There is no difference, they will both do the same thing
|
|
|
|