top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C: How does macro function works as compare to normal function ?

+1 vote
526 views

What all things need to be taken care while writing macro function which has multiple lines ?

posted May 22, 2016 by Vikram Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

Hi Vikram, I think you should read this article to know your answer where differences between macro and normal functions are explained very well.
Link : http://tech.queryhome.com/50776/difference-between-macro-and-function
Author : Salil Agrawal and for your second ques in "explanation section"
For writing multiple line Macros,

each statement ends with “\”

example :

You use \ as a line continuation escape character.

#define swap(a, b) {               \
                       (a) ^= (b); \
                       (b) ^= (a); \
                       (a) ^= (b); \
                   }

follow these links to know more rules while writing multiple line macros
1.http://www.oualline.com/books.free/style/c06.html
2.http://www.geeksforgeeks.org/multiline-macros-in-c/

answer May 23, 2016 by Shivam Kumar Pandey
Similar Questions
+1 vote

Suppose a macro eNodeB supports multiple cells. Does each cell has its own instance for each layer or one instance of each protocol layer can handle more than one cell ?

+1 vote

On what factors, cell coverage is decided and how does an operator chose ?
Is it always good to chose broader coverage ?

0 votes

Is it possible to call a Python macro from ctypes? For example, Python 3.3 introduces some new macros for querying the internal representation of strings:
http://www.python.org/dev/peps/pep-0393/#new-api

So I try this in 3.3:

py> import ctypes
py> ctypes.pythonapi.PyUnicode_MAX_CHAR_VALUE
Traceback (most recent call last):
 File "", line 1, in 
 File "/usr/local/lib/python3.3/ctypes/__init__.py", line 366, in __getattr__
 func = self.__getitem__(name)
 File "/usr/local/lib/python3.3/ctypes/__init__.py", line 371, in __getitem__
 func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python3.3: undefined symbol: PyUnicode_MAX_CHAR_VALUE
...