|
however, if i just add A to listA but add B to listB
^^^^
it should be "...but NOT add B to..."
thanks,
jim
|
|
|
|
|
Post code. Helps much.
"Perhaps the truth is less interesting than the facts?" -- Amy Weiss, RIAA's Senior Vice President of Communications. It's the new math! 421 == 156 !
|
|
|
|
|
part "add to list"
/*** add A to list A (code is the same inside AddToCommandList) ***/
AddToCommandList(tar_moni_id, tar_port_num, control, priv);
/*** add B to list B ***/
binding_ack_list *pAck = new binding_ack_list;
pAck->moni_id = moni_id;
pAck->tar_moni_id = tar_moni_id;
pAck->tar_port = tar_port_num;
pAck->done = false;
sysinfo.bindingacklist.AddTail(pAck);
part "use the list"
void CPooling::CommandControl()
{
byte data[16];
data[0] = 0xff;
data[2] = 0x34;
data[3] = 0 ;
data[8] = 0xfe;
cmd_list *pCommand;
POSITION pos1, pos2;
CString temp;
m_CS.Lock();
for (pos1 = sysinfo.cmdlist.GetHeadPosition(); (pos2 = pos1) != NULL;)
{
pCommand = sysinfo.cmdlist.GetNext(pos1);
if (pCommand->trial > 2)
{// remove
sysinfo.cmdlist.RemoveAt(pos2); //remove in list if trial > 3
delete pCommand;
}
else
{// read
data[1] = pCommand->moni_id;
data[4] = pCommand->port;
data[5] = pCommand->control;
data[6] = pCommand->priv;
data[7] = genChkSum(data, 6);
pCommand->trial++;
for (int i=0; i<9; i++)
{
p232->WriteComm(&data[i], 1);
Sleep(100);
}
//p232->WriteComm(data, 9);
Sleep(timeout);
}
}
m_CS.Unlock();
}
Once it return from this function, the program crash!!!
|
|
|
|
|
The code is pretty torn up, and the For-pos statment is missing the last half - I assume it's an empty statment, since the pos1 would be changed by the GetNext.
Try commenting out the delete pCommand and the RemoveAt lines and see if that changes anything. If not, then comment out the write to your serial port (I am assuming that is what your p232 object is). If that fixes it, then it's the code for that, not the loop.
"Perhaps the truth is less interesting than the facts?" -- Amy Weiss, RIAA's Senior Vice President of Communications. It's the new math! 421 == 156 !
|
|
|
|
|
hey! i tried to remark the serial port. and, It really work???
it is my fault or VC's debug mode having error? (it work in release mode!)
thanks,
jim
|
|
|
|
|
I have no idea - I don't know what the code in your serial port object looks like.
"Perhaps the truth is less interesting than the facts?" -- Amy Weiss, RIAA's Senior Vice President of Communications. It's the new math! 421 == 156 !
|
|
|
|
|
Check out: http://www.codeproject.com/debug/survivereleasever.asp
Adi
|
|
|
|
|
You are probably corrupting some memory location, and the memory you are corrupting happens to cause a crash in debug but not release mode.
e.g. possibly allocating 10 bytes and using 20, referencing a pointer that is not set or pointing to some random memory location. Peronaly I set all pointer to NULL when I declare them, to prevent this sort of thing happening.
Either bench test the code, or run it through a program like "Bounds Checker"
|
|
|
|
|
I just installed Visual C++ and wrote a simple program that would not compile. I know I have to set the path right, but it seems fine to me. Here's the code, error and path description. Contribute in anyway you can.
AIM: ezelame
//first c++ program
#include <iostream.h>
int main()
{
//cout << "Hello World!\n";
return 0;
}
error: c:\Documents and Settings\Eze Kamanu\My Documents\c++\test\first.cpp(8) :
fatal error C1010: unexpected end of file while looking for precompiled header directive
path: C:\Program Files\Microsoft Visual Studio .NET\Vc7\include;
|
|
|
|
|
king_ezela wrote:
fatal error C1010: unexpected end of file while looking for precompiled header directive
Put cursor on error line. Hit f1. Read. Scratch head. Realize that you have failed to Read The Friendly Manual before starting. Do so. Go back and correct the totally bogus #include line. Try again, young jedi.
"Perhaps the truth is less interesting than the facts?" -- Amy Weiss, RIAA's Senior Vice President of Communications. It's the new math! 421 == 156 !
|
|
|
|
|
Dude, chill. The poster is new to Visual C, don't be a smartass when he's obviously struggling just to get started.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Looks like you're missing #include "stdafx.h" at the top of your .cpp file.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks a lot, it did work. Real dumb question, how do I run the program (see the output) after compiling?
|
|
|
|
|
Press F5
|
|
|
|
|
Since you are using Visual Studio.NET try the following:
#include "stdafx.h"
#include <iostream.h>
#using <mscorlib.dll>
#include <tchar.h>
using namespace System;
int main(void)
{
cout << "Hello World!\n";
return 0;
}
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
Hi Ezela, I see you got this particular problem solved, but please check out the Visual C++ forum FAQ (there's a link to it at the top of this page) that addresses other common compiling problems that you might encounter.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
it's obvious.
look at the #include line. you don't specify what to include.
it should be something like this
#include "stdafx.h"
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Hi:
I'm a newbie Visual C ++ programmer, and I'm trying to do a Simple chat using winsock.ocx, I have already done one in VB5 but now I would like to do it in VC.
Mainly, i'm having problems with .Connect metod, I don't understand what Const VARIANT &RemoteHost and Const VARIANT &RemotePort means.
PD: I have a chat example but it uses API and i would like to do it just using winsock.ocx.
Thanks and I hope you help.
This is the strangest life I've ever known.
|
|
|
|
|
RaulGonzalez wrote:
Mainly, i'm having problems with .Connect metod, I don't understand what Const VARIANT &RemoteHost and Const VARIANT &RemotePort means.
These parameters it is asking for is the "address-of" by the "&" sign for both the RemoteHost and the RemotePort variables being passed to the function. I would suggest that you read Andrew Peace's article on pointers. A Beginner's Guide to Pointers[^]
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
ok, I'm on it, thanks. Um, do you know where could i get a chat sample using winsock.ocx ? )
This is the strangest life I've ever known.
|
|
|
|
|
Sample code in C++ is probably going to use the APIs, since That's How It's Done in C++. (I don't even have winsock.ocx on my system, either)
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Michael Dunn wrote:
(I don't even have winsock.ocx on my system, either)
Mike,
It should come with Visual Studio however the only place I have ever seen it used is with Visual Basic. It's in the Windows\System32 folder.
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
RaulGonzalez wrote:
ok, I'm on it, thanks. Um, do you know where could i get a chat sample using winsock.ocx ? )
Are you using MFC?
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
Yes, i'm using MFC AppWizard (exe)...
This is the strangest life I've ever known.
|
|
|
|
|