LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-19-2019, 02:06 PM   #1
jani1
LQ Newbie
 
Registered: Dec 2019
Posts: 7

Rep: Reputation: Disabled
How to interpret relational operators in a macro?


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
 
Old 12-19-2019, 02:43 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,872
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Maybe you were using 'mcedit' to see the content of this file?
'mcedit' displays Tabulator character as <------>

Last edited by NevemTeve; 12-19-2019 at 02:46 PM.
 
1 members found this post helpful.
Old 12-19-2019, 03:19 PM   #3
jani1
LQ Newbie
 
Registered: Dec 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
I'm using vim editor to see contents of this file.
 
Old 12-19-2019, 03:25 PM   #4
jani1
LQ Newbie
 
Registered: Dec 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
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?
 
Old 12-19-2019, 04:37 PM   #5
Geist
Member
 
Registered: Jul 2013
Distribution: Slackware 14 / current
Posts: 442

Rep: Reputation: 196Reputation: 196
Quote:
Originally Posted by jani1 View Post
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.
 
2 members found this post helpful.
Old 12-19-2019, 08:20 PM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,872
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
In vim-8.0, :set nolist worked for me.
 
1 members found this post helpful.
Old 12-20-2019, 07:40 AM   #7
jani1
LQ Newbie
 
Registered: Dec 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
>> 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"


:set nolist also worked for me. Thank you!
 
Old 12-20-2019, 11:07 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,957

Rep: Reputation: 7329Reputation: 7329Reputation: 7329Reputation: 7329Reputation: 7329Reputation: 7329Reputation: 7329Reputation: 7329Reputation: 7329Reputation: 7329Reputation: 7329
Quote:
Originally Posted by jani1 View Post
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? Do you have a test code or an example to work with?
 
Old 12-20-2019, 11:15 AM   #9
jani1
LQ Newbie
 
Registered: Dec 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
>> 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.
 
Old 12-20-2019, 03:39 PM   #10
Geist
Member
 
Registered: Jul 2013
Distribution: Slackware 14 / current
Posts: 442

Rep: Reputation: 196Reputation: 196
Quote:
Originally Posted by jani1 View Post
>> 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.

This link has a more in depth overview, including some pitfalls to look out for and how to deal with them.
 
1 members found this post helpful.
Old 12-22-2019, 05:39 PM   #11
jani1
LQ Newbie
 
Registered: Dec 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
>> it was the wording, though.
Yes, okay.

Thank you for answer and link.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Linux C Programming Tutorial Part 11 - Arithmetic, Relational, and Logical operators LXer Syndicated Linux News 0 03-14-2019 01:33 AM
LXer: Relational vs. Non-Relational Databases: The Tide Is Shifting LXer Syndicated Linux News 0 03-13-2017 03:51 PM
#defining a macro inside a macro? saravkrish Programming 1 05-24-2005 09:48 PM
Are there any gui relational databases available for linux? donlinux Linux - Software 3 03-18-2004 08:52 PM
Relational Database on Linux Ronw Linux - Software 10 11-11-2003 02:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration