[SOLVED] How to interpret relational operators in a macro?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Please provide an example that uses following macros.
What part is macro, and what part is replacement token?
filename: linux/arch/include/asm/cache.h
Code:
/* Largest line length for either L1 or L2 is 128 bytes */
50 #define SMP_CACHE_BYTES>> 128
51 #define cache_line_size()>SMP_CACHE_BYTES
52 #define ARCH_DMA_MINALIGN>SMP_CACHE_BYTES
I'm seeing these characters > and >> in other lines as well.
struct usb_device {
105 > int>devnum;>> > /* Device number on USB bus */
106 > int>speed;> > > /* full/low/high */
107 > char> mf[32];>> > /* manufacturer */
108 > char> pro
Why does vim display these characters?
It's the
Code:
set list
options,
Code:
set nolist
to turn it off and
Code:
set listchars=tab:>-,trail:-
to change how they look.
Anyway, this looks like homework, so, work on it :P
If you were to add macros into the C language, how would you do it? Maybe that will help.
Think about the syntax of the C language.
>> this looks like homework
I'm not a student. I'm trying to learn USB host implementation in u-boot so I can write USB Host code to detect unusual device that is USB Device Class "Vendor Defined"
>> How is this related to the original post?
It's not related to the original post. I was just trying to give reason as to why my original question isn't homework.
>> How is this related to the original post?
It's not related to the original post. I was just trying to give reason as to why my original question isn't homework.
Haha, fair, it was the wording, though.
Quote:
Please provide an example that uses following macros.
What part is macro, and what part is replacement token?
It's something you might find in a textbook.
Anyway, the macro name comes first, the definition comes afterward.
Code:
#define macro_name return 0
int return_null()
{
macro_name;
}
Note that the macro_name does not have a semicolon at the end, that's because the word "macro_name" gets expanded into the text you have given, think of it like a copy paste.
There's a lot more to it, of course, but that's basically how a macro is set up, the name you define for it, and then the text you want it to represent.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.