473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

macros

I was browsing the linux kernel source and came across something I've never
seen. Here's an example

#define (thismacro)
#define (1<<(thismacro))

What is this doing? Why the parenthesis around the macro defines, on each
line?

Bill

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 13 '05 #1
4 2156
Bill Cunningham <no****@net.net> scribbled the following:
I was browsing the linux kernel source and came across something I've never
seen. Here's an example #define (thismacro)
#define (1<<(thismacro)) What is this doing? Why the parenthesis around the macro defines, on each
line?


I don't think #define (1<<(thismacro)) is valid C syntax at all.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I am looking for myself. Have you seen me somewhere?"
- Anon
Nov 13 '05 #2
On Thu, 16 Oct 2003 02:32:43 -0400, Bill Cunningham wrote:
I was browsing the linux kernel source and came across something I've never
seen. Here's an example

#define (thismacro)
#define (1<<(thismacro))

What is this doing? Why the parenthesis around the macro defines, on each
line?


Doesn't look like C, are you sure you didn't miss anything in your
example? It might be a gcc specific thing though, but a quick glance at
the gcc info pages didn't shed any light on it.

Looking at the actual usage instead of your example might help shed some
light on it.
Kernel version?
File?
Line?

regards
--
NPV

"the large print giveth, and the small print taketh away"
Tom Waits - Step right up

Nov 13 '05 #3
Joona I Palaste <pa*****@cc.helsinki.fi> spoke thus:
#define (thismacro)
#define (1<<(thismacro))
I don't think #define (1<<(thismacro)) is valid C syntax at all.


Neither is #define (thismacro), for that matter, right? gcc says that macro
names must be identifiers...
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 13 '05 #4

"Nils Petter Vaskinn" <no@spam.for.me.invalid> wrote in message
news:pa****************************@spam.for.me.in valid...
On Thu, 16 Oct 2003 02:32:43 -0400, Bill Cunningham wrote:
I was browsing the linux kernel source and came across something I've never seen. Here's an example

#define (thismacro)
#define (1<<(thismacro))

What is this doing? Why the parenthesis around the macro defines, on each line?


Doesn't look like C, are you sure you didn't miss anything in your
example? It might be a gcc specific thing though, but a quick glance at
the gcc info pages didn't shed any light on it.

Looking at the actual usage instead of your example might help shed some
light on it.
Kernel version?
File?
Line?

regards

It figures. Now I can't find it but I believe it had something to do with
sys calls or calling sys calls. I'll keep looking. I'm almost sure I've seen
code like

#define (something)

before in a header or source file. But if it's a syntax error, maybe I'm
mistaken.

Bill

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
16
by: mike420 | last post by:
Tayss wrote: > > app = wxPySimpleApp() > frame = MainWindow(None, -1, "A window") > frame.Show(True) > app.MainLoop() > Why do you need a macro for that? Why don't you just write
37
by: michele.simionato | last post by:
Paul Rubin wrote: > How about macros? Some pretty horrible things have been done in C > programs with the C preprocessor. But there's a movememnt afloat to > add hygienic macros to Python. Got any...
8
by: Michael Winter | last post by:
In a recent post ("About C error" by Victor, 21 Sep 2003), comments were made about the poster's use of macros. What I would like to know is why they are considered bad? I'm not referring to...
11
by: Ben Hetland | last post by:
....in certain cituations they can be useful if not for anything else, then at least for saving a lot of repetetetetetitititive typing. :-) Beyond the point of "do something better instead", I'm...
3
by: Stephen Sprunk | last post by:
On a project I'm working on, I ran across the following macros: /* assume s is struct stream *, s->p is char, v is unit16_t or uint32_t */ #define in_uint16_le(s,v) { v = *((s)->p++); v +=...
47
by: Emil | last post by:
Is there any hope that new versions of PHP will support macros similar to C or C++? I've searched manual and didn't find anything except define directive, but it can be used to define constant...
11
by: San | last post by:
hi there, I am new to c++ and tryig to learn the basics of the c++ concepts. While I was reading the templates, I realize that the templates are a syntax that the compilar expands pased upon the...
33
by: Robert Seacord | last post by:
When writing C99 code is a reasonable recommendation to use inline functions instead of macros? What sort of things is it still reasonable to do using macros? For example, is it reasonable to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.