Home > Software engineering >  A thorny issue of the definition of # define macros, the replacement of grammar or see for the first
A thorny issue of the definition of # define macros, the replacement of grammar or see for the first

Time:10-04

code a Duan Hong are defined as follows:

# define CLASS_THREAD (c, x) \
Rp: : Hal: : Thread: : create_member & lt; C., & amp; C: : x> (this)


For the younger brother didn't understand what that means, the replacement of grammar or see for the first time, also please give some directions passing down,,,,

CodePudding user response:

[color=# FF0000] detailed code is
[/color]
# pragma once

# include "rptypes. H"
# define CLASS_THREAD (c, x) \
Rp: : Hal: : Thread: : create_member & lt; C., & amp; C: : x> (this)

The namespace rp {namespace Hal {

The class Thread
{
Public:
Enum priority_val_t
{
PRIORITY_REALTIME=0,
PRIORITY_HIGH=1,
PRIORITY_NORMAL=2,
PRIORITY_LOW=3,
PRIORITY_IDLE=4,
};

The template & lt; The class T, u_result (T: : * PROC) (void) & gt;
The static Thread create_member (T * pthis)
{
Return the create (_thread_thunk & lt; T, PROC> Pthis);
}

The template & lt; The class T, u_result (T: : * PROC) (void) & gt;
The static _word_size_t THREAD_PROC _thread_thunk (void * data)
{
Return (static_cast & lt; T * & gt; (data) - & gt; * the PROC) ();
}
The static Thread the create (thread_proc_t proc, void * data=https://bbs.csdn.net/topics/NULL);

Public:
~ the Thread () {}
The Thread () : _data while forming (NULL), _func (NULL), _handle (0) {}
_word_size_t getHandle () {return _handle; }
U_result the terminate ();
Void * getData () {return _data while forming; }
U_result join (unsigned long timeout=1);
U_result setPriority (priority_val_t p);
Priority_val_t getPriority ();

Boolean operator==(const Thread & amp; Right) {return this - & gt; _handle==right. _handle; }
Protected:
The Thread (thread_proc_t proc, void * data) : _data while forming (data), _func (proc), _handle (0) {}
Void * _data while forming;
Thread_proc_t _func;
_word_size_t _handle;
};

}}

CodePudding user response:

VS the IDE in don't understand the symbol on the right mouse button, choose to define,

CodePudding user response:

[ask] "_cachethread=CLASS_THREAD (RPlidarDriverSerialImpl _cacheCapsuledScanData);" , dating back to the thread. H header file, macro definition about CLASS_THREAD:

"# define CLASS_THREAD (c, x) \
Rp: : Hal: : Thread: : create_member & lt; C., & amp; C: : x> (this) ", will replace, find the right hand side _cachethread statement seems to do not conform to the grammar, don't know whether our replacement process is wrong,

Can you tell me whether the replacement process is wrong?
_cachethread=rp: : Hal: : Thread: : create_member & lt; RPlidarDriverSerialImpl, & amp; RPlidarDriverSerialImpl: : _cacheCapsuledScanData & gt; (this);

Compiled an ERROR result is an INTERNAL COMPILER ERROR, compile the INTERNAL ERROR,

Assignment statements, please the equals sign expression down on the right side of a comma, the semicolon at the end, this structure can compile? A=B c; Really don't understand!

CodePudding user response:

VC compiler options/EP/P (projects, properties, configuration properties, C/C + +, the preprocessor, pretreatment to the file: is that the preprocessing cancel display line Numbers: is), recompile, view the corresponding after macro expansion. I file, GCC - E http://bbs.csdn.net/topics/391003898
  • Related