View
Macro expansionThere are three methods. Only two methods have been tested, and the last one has not been tested.
- Use the GCC command;
- Use the Command provided by VC;
- Source insightTools;
1. in GCC, run the command-e
The following code
# Include <objbase. h>
# Include <initguid. h>
# UNDEF Interface
# Define interface iexample
Declare_interface _ (interface, iunknown)
{
Stdmethod (QueryInterface) (This _ refiid, void **) pure;
Stdmethod _ (ulong, addref) (this) pure;
Stdmethod _ (ulong, release) (this) pure;
Stdmethod (setstring) (This _ char *) pure;
Stdmethod (getstring) (This _ char *, DWORD) pure;
};
You can save the code as a file in test. h or another format.
Gcc-E test. h> E:/out.txt
Open the out.txt file of the edrive. The following content is displayed at the bottom of the file:
Typedef struct iexample {struct iexamplevtbl * lpvtbl;} iexample; typedef struct iexamplevtbl; struct iexamplevtbl
{
Hresult (_ attribute _ (_ stdcall _) * QueryInterface) (iexample *, const IID * const, void **);
Ulong (_ attribute _ (_ stdcall _) * addref) (iexample *);
Ulong (_ attribute _ (_ stdcall _) * release) (iexample *);
Hresult (_ attribute _ (_ stdcall _) * setstring) (iexample *, char *);
Hresult (_ attribute _ (_ stdcall _) * getstring) (iexample *, char *, DWORD );
};
_ Attribute _ is a keyword of GCC used to describe variable attributes.
2. In VC, you can also add the/p command at the end of project option under project-> setting-> C/C ++ /.
After rebuild all, some errors will be prompted. It doesn't matter. There will be a. I file under the directory where the project is saved.
You can also find the same content as out.txt in the corresponding location.
3. Source insight is also supported, but it has not been tested.