Some experiences about VC ++ programming

xiaoxiao2021-04-05  255

No .: 001 Time: 2005-5-19 14:16 Description: Added part source code for different types of address operations as follows: typedef struct {byte flag; // 0 Indications, 1 means feedback Byte Content; // Command Content BYTE HOSTNUM; // Transmitter Sequence Unsigned Short Segnum; // Inclique

Pack_cmd * pcmd;

INT NONE = (char *) PCMD 10; int NTWO = (char *) (PCMD 10);

Question: Does NONE are equal to NTWO? Solution: Will not wait. Plus 10 characters long on the basis of the PCMD address; and the latter adds 10 pack_cmd lengths, which is the length of sizeof (pack_cmd). No .: 002 Time: 2005-5-19 14:24 Description: The impact about the VC compiler byte alignment option to the sizeof () function

Question: Sizeof (pack_cmd) in 001 is equal to 9? Answer: Not necessarily. This is a big relationship with the VC compiler byte alignment option. If it is aligned, its value is equal to 9; but when pressed 8 When the byte is aligned, sizeof (pack_cmd) is equal to 10.

No .: 003 Time: 2005-5-24 17:45 Description: About serial communication

Some pseudo code is as follows:

Void sendcomcmd // Send CMD to the serial port controller {// sending COM command}

Void SomeneBuuton_Click () {pack_cmd cmd1, cmd2; sendcomcmd (cmd1); // a control command sendcomcmd (cmd2); // another control command}

Question: Will communication in the function SomePuuton_Click? Solution: In most cases, it will not be normal. Destipline (Master) It is very likely that the cmd1 is also sent when the cmd1 is still in the future, and the cmd2 command has been sent. At this time The situation of the machine see is that the cmd1 is not received. Therefore, it is necessary to have a delay between them, the time is slightly larger than the size of the transmitted data (0.1 milliseconds / bit). As here Pack_cmd is 10 bytes, which is enough to take 10 milliseconds.

The following code can work properly: void someonebuuton_click () {pack_cmd cmd1, cmd2; sendcomcmd (cmd1); // a control command SLEEP (10); // delay 10 millisecond Sendcomcmd (cmd2); // another one control commands}

No .: 004 Time: 2005-5-27 9:07 Description: About the debugger

The recording program was successfully debugged before, and the network was sent successfully. After reliable, the polling mechanism is used. The lower machine will send a online command every time, the upper chance will put this next machine ID into a queue In the middle, the host machine checks the ID in this queue every 30 seconds, there is an online, it is not online, but it is not online; then it finds that a recording is noise. Why? 1, there may be recording itself Question? 2, the recording is no problem, it is possible to send a problem? 3, students recording, send no problem but the host machine accepts problems? Write the data that should not be written? 4, the upper machine is also completely correct data, But if there is a problem? 5, there is no problem with the host computer, but the data received by the student machine has problems? It should be such a process, one step checking. These steps are there without problems, what is the problem? Finally, I think that the next machine will send an online command to the host computer every 10 seconds. I think about it, the next machine It can only send data from one port. When the recording is recorded, the next machine has sent an online command. It is that port is that port, so it is doubt that the next machine also sends the online command to the host computer recording and receiving ports. I have been suspecting that it is a problem of a host computer, because in this process I will receive and send recorded data AX files to recompile if this is the cause of transmission or reception. But I can't, before, before I have tried it in Shenzhen. I have no problem. Why is there any problem? Maybe I can only be attributed to the luck. For example, the time interval of the student's online command is long, then this time interval, there is no online command to send Come over, and the recording is stopped in this time interval, and then the play is of course nothing. Because there is no other illegal data to enter the recording and receive port. So I think, when there is a problem like this, I should think more. I want to have something to do now, especially when I work, I don't think about this idea, then this question is not for a long time. No .: 005 Time: 2005- 7-14 11:15 Description: The establishment of the (VC ) debugging environment

Some source code is downloaded from the Internet today. It is a ready-made project! I want to make a single step debugger, see how the program is running. But I will always pop up a conversation, what you set is invalid or breakpoint Clicked. Click "Project" -> "Project Setting" -> "debug" option will see the execution file under the Release version. I think it may be due to this problem, so I want to change your work Under the Debug folder, it is still not possible to tick the environment that produces debugging information. It suddenly found the "setting for" option for the Release version several times, so I changed it as a Debug version. Try again, or debug. Then I think Is it only because the document downloaded is read-only, it is not used in the VC environment. Well, set the folder of the entire project to "document" attribute, and the results are still the same! This is wonderful, Why? Think about it, sometimes some questions about the environment in the future is to delete those configuration files (anyway to delete and compile it :)) Don't solve most of the problems! If you delete these files (including * .ncb, *. Plg, release folders), and debugging it.

No .: 006 Time: 2005-7-26 17:30 Description: Related (VC ) Compile Environment Today you need to organize the colleague's procedure, but when you are loaded into VC , the speed is slow, and it will open the project for a long time. Experience has issued a problem with several profiles (NCB, OPT, APS, CLW, etc.) that may be engineered. The four files are deleted until the results are still the same. After the next time the opening process is opened for the first time. Compared to the situation, not only don't have a big improvement, and there are often VC unusual crashes. So doubt whether it is a problem with your own VC environment. Restore the operating system, VC should have no problem! Test again, or the previous situation is similar. When all the documents of observing the project, there were two resource files. I thought it was not the resource file. I opened the second resource file. There was very little content, the file size was only 1k. Maybe there is no problem! Try Take the second resource file to look at the results, and there is no good change. When you look at the first RC file, it is very surprisingly found that the RC file has 26m. According to experience, it is impossible, One project has 26M resource files. It seems to be difficult. Use UltraEdit32 to further open observation specific content, found that there is a very different in one of the MSFlexGrid controls in the dialog, which is estimated to describe the table's data has a large amount of "0x0000000000 "" The data is more than 25M, so it is only necessary to use these data, and this data has led to a slow engineering load speed. On the data COPY before "0x00000", put one down In one file, then put the valid data of the end sections to this file, name and replace it with the RC suffix. Re-load should work, surprise appear: Can quickly compile the project, and there is no mistake! Very happy! Accepting trying to use, but found that one of the tables discovered that he was dead! So in the workspace to find this dialog, it is found that the table on this dialog is blue and does not display the relevant properties of the table. So decision Simply delete this form! Re-put on a form, the same name, the relevant attributes are also the same as before, and then recompile the project, and use everything. Summary: Touching a similar problem to carefully observe the project Each file is decided which part has problems. Then look at the problem. For the above questions, there is a way to directly delete the table on the relevant dialog, it is estimated that the problem can also be solved.

转载请注明原文地址:https://www.9cbs.com/read-132165.html

New Post(0)