Who can help with the strange linux multi-thread programming errors ??

Source: Internet
Author: User
Who can help with the strange linux multi-thread programming errors ?? -- Linux general technology-Linux technology and application information. For details, refer to the following section. I recently wrote a simple server program under ubuntu10.10, but there was a strange error. I have not found the cause so far. The details are as follows:

The main thread listens to port data and adopts the select method. The next thread accepts commands to control the data output of the serial port. So I thought of using the structure as a global variable, share data between threads (I don't know how to handle data sharing, which is usually used in most cases ). However, a problem occurs in the sub-thread (the main thread and the sub-thread are not in the same file). The prompt is as follows:
Error: request for member 'ctrollkind' in something not a structure or union
Error: request for member 'ctrollnum' in something not a structure or union
Error: request for member 'ctrolltype' in something not a structure or union

The structure is declared in the header file of the main thread and defined in the main thread. The Code is as follows:
Typedef struct ctroll ctr;
Struct CTROLL
{
Int ctrollKind;/* ctroll the motor or led */
Int ctrollType;/* the ctroll kind turn on or turn off */
Int ctrollNum;/* the number of the led */
};

The structure is defined in the main thread. The Code is as follows:
CTR ctroll;

The time code used by the sub-thread is as follows:
Extern ctroll;
...
Ctr_kind = ctroll. ctrollKind;
Num = ctroll. ctrollNum;
Action = ctroll. ctrollType;

The above problem occurs during compilation. The strange thing is that I used the same method and shared another variable without prompting similar errors.
After checking for a long time, I also found a lot of relevant information on the Internet, but I was confused these days. Who can help.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.