|
Thanks for your time,
I should ask this. May be barcode generating process is slow
|
|
|
|
|
Mohibur Rashid wrote: May be barcode generating process is slow It depends on your code and your printer. I have my own barcode print routine which is fast enough for my purposes.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I watched it all. the data transfer is slow. But network is not slow. It actually take time to transfer data. The printer is high performance printer. I need to calculate how much time it takes time to generate single barcode
|
|
|
|
|
Mohibur Rashid wrote: I need to calculate how much time it takes time to generate single barcode If you mean inside your code then that's easy, just take the time at the start and end of your print process. If you mean from the PC to the printer I do not know of any simple method. Also different printers operate in different ways with regard to when they start printing relative to when the print data arrives.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Yeah, the program sucks. I re-write the entire code, took few hours. working fine and fast
|
|
|
|
|
Hi, dear all,
I create a DLL that will apply calculation.
class __declspec(dllexport) Class1{}
class __declspec(dllexport) Class2{}
class __declspec(dllexport) Utility{
static Class1* CreateCase1Obj(){
Class1* obj = new Class1();
return obj; }
}
Other application will use the Utility to get Class1 object as the following:
Class1* obj = Utility::CreateCase1Obj();
The error happens inside CreateCase1Obj() function while call "return obj;" and browser points to dbgheap.c file.
Can anybody tell me what cause this error? Thanks!
|
|
|
|
|
Probably crashing because you're attempting to create a class from code you never imported.
|
|
|
|
|
Thanks for your reply.
In my project's cpp file from where I will call function from DLL, I add the following lines at the file top:
__declspec(dllimport) class Class1;
__declspec(dllimport) class Class2;
__declspec(dllimport) class Utility;
but still get the same error.
|
|
|
|
|
I test the program, the reason for the error is that I pass std::string as argument to Class1 constructor.
Class1(std::string arg1, std::string arg2){
this.ProjDir = arg1.data();
this.ProjName = arg2.data();
}
calling side:
std::string dir = ".....";
std::string name = "....";
Class1 obj = new Class1(dir name);
I test if I call empty constructor, it's fine.
What should I do now? I need to pass these value to Class1.
|
|
|
|
|
Try using the c_str() [^] member function to get the data from the string parameters.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Richard, thanks for your suggestion.
Yes, if in the calling side I pass string.c_str() value
string xx = "calling...";
func(xx.c_str());
and in the function definition side I define function as:
func(const char* str){}
everything is fine.
But my project has hundreds functions, it was created in C++ 6.0, now I wish to migrate it to VS2008, if I have to modify all the function definition and modify all the places to function call, that's a big work.
Is there any better way to solve this issue? Thanks!
|
|
|
|
|
I do not know of any simple way other than "Find & Replace in Files" (Ctrl+Shift+H). It's a pity that you created the functions to accept char* parameters rather than string object references, then you would not have had to change in so many places.
[edit]
It is, of course, always possible, that the 'bug' in your code will not be fixed by these changes, but is connected to something else. Make sure that you are actually fixing the right problem before you make all these changes.
[/edit]
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I am testing to pass std::string by reference instead of std::string, it works fine. so in this case, all I need to do are modify all the function siguratures with std::string as argument, that saves a lots of time.
Thanks!
|
|
|
|
|
I also just noticed that in one of your earlier posts you are using std::string s for string constants. This is a waste of time as you are just adding extra code to copy the constant character value into a std::string in order to pass it to some function.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Yes, this issue is caused by pass std::string between EXE and DLL.
When I search the solution from internet, all say that you canno pass std::string between DLLs, you'd better pass C-style character string, that's way I convert std::string to char*.
Now since passing std:: string by reference can solve the issue, that's best.
|
|
|
|
|
Andraw111 wrote: this issue is caused by pass std::string between EXE and DLL. I'm sure it's more than just that.
Andraw111 wrote: you canno pass std::string between DLLs If that were true you would not be able to pass any objects between DLLs.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Looks like you're crashing because of heap corruption. The crash is almost certainly happening in the "Class1* obj = new Class1(); " line (it's common for the line number to indicate the line after actual call in question), the "dbgheap.c" all but proves it.
With heap problems the actual root cause (when the heap got corrupted) and the resulting crash (in your case when the heap manager detects it) can be separated but quite some time, which makes it difficult to debug.
I'll take a wild quess at the cause however:
Looks like the new statement with allocates the object is in the DLL. How is it delete d? By a delete statement in the DLL's client? If so try moving it into the DLL where it belongs:
void DeleteCase1Obj(Class1 *obj)
{
delete obj;
}
Replace all delete s of this object in the client with calls to this function which is exported from the DLL.
Steve
|
|
|
|
|
Hi, dear all,
I have a DLL file created in C++ 6.0, now move to VS2008 and get compile error.
in header file:
#define XXXPORT __declspec(dllimport)
template <class TP> class XXXPORT TPtrList
{
public:
int entries(bool deleted = false) const;
TP *operator[](int n);
const TP *operator[](int n) const;
..............
..............
}
in .cpp file
template <class TP>
inline int TPtrList<TP>::entries(bool deleted) const
{
.........
}
template <class TP>
inline TP *ABSTPtrList<tp>::operator[](int n)
{
.........}
In C++, they are fine, but in VS2008, When I compile it, I got
error C2491: 'TPtrList<TP>'::entries' : definition of dllimport function not allowed
error C2491: 'TPtrList<TP>::operator []' : definition of dllimport function not allowed
What cause this problem? Thanks!
|
|
|
|
|
This looks like you're defining the functions when doing the dll import... when all you should have is function prototypes. You probably want to define XXPORT up there to say dllexport.
|
|
|
|
|
Yes, you are right.
I just change to dllexport, then I can add function implementation to it, so can be used by other class inside this DLL.
Thanks!
|
|
|
|
|
Hi, dear all,
I create a class name Point2D to store coordinate value, with "<" and "==" two operators overloadings.
Then create a type based on it as:
typedef std::vector<Point2D*> Point2D_Vector;
Point2D_Vector PointVector;
Then add some data to PointVector.
When I loop the vector:
Point2D_Vector::iterator itr;
for (itr=PointVector.begin(); itr!=PointVector.end(); itr++)
if (itr != 0)
delete *itr;
They work fine in C++6.0, now when I try to compile it in VS2008 I got the error message in if(itr != 0) line:
error C2679: binary '!=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
How can I solve this issue? Thanks!
|
|
|
|
|
|
The statement itr != 0 makes no sense. Even when it compiled in VC6 it wasn't doing what it looks like you intended (to stop deleting a NULL pointer). You probably mean this:
if (*itr != 0)
Also, deleting a NULL pointer is safe in C++ (it does nothing). The check is not needed and it potentially makes the code less efficient as the compiler inserts code to check for this automatically.
Steve
|
|
|
|
|
Thanks, Chris and Steve, it can be compiled now.
|
|
|
|
|
a code to change string to uppercase using integer values within the code.
|
|
|
|