473,473 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Macros Vs typedef

52 New Member
Hi All,
What is basic difference using macors and typedef in C program

Thanks
Sridhar.D
Jan 10 '10 #1
2 4187
weaknessforcats
9,208 Recognized Expert Moderator Expert
A typedef just renames an already existing type. If all your macro does is provide an alias for a type, then the macro and the typedef are identical functionally.

Expand|Select|Wrap|Line Numbers
  1. typedef  int NUMBER;
  2.  
  3. #define NUMBER  int
However, a macro can be used to represent blocks of code which a typedef cannot.
Jan 10 '10 #2
sridhard2406
52 New Member
Thanks for your reply
Jan 11 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

37
by: hasadh | last post by:
Hello, probably this may be a simple qn to u all but I need an answer plz. In my software i used macros like OK,TRUE,FALSE,FAILURE . A friend who included this code as a library into his module...
7
by: hierro | last post by:
I have a list of functions (all with suffix T). For each one, I need to implement the following: FunctionT() { if (some_condition) { // do some conversion first FunctionW(); // then do some...
1
by: rir3760 | last post by:
Since a few days ago I have been working with the program I post below (a school assignment). The purpose of the program is to work with the va_ macros (stdarg.h) and arrays of arrays, hopefully...
5
by: drequena | last post by:
Hi All, I'm not that expert at C but I'm trying to understand some code that does extensive use of the following two preprocessor macros: #define WORD(ptr) (((*(octet *)(ptr))<<8)|(*(octet...
2
by: Piotr Sawuk | last post by:
What is the proper c++-way of saying: template <class Container_> struct forwards_iterator_toggle { typedef Container_ Container; typedef typename Container::iterator iterator; typedef...
4
by: a_agaga | last post by:
Hi! Do you know different alternatives to convert exceptions in many methods of some wrapper classes. User -Wrapper classes -LibraryClasses -... Wrapper classes catch an exception of only...
1
by: greek_bill | last post by:
Hi all, I'd like to have code that looks like the following : BEGIN(Foo) ADD(float); ADD(int); ADD(char); END()
0
by: skaura | last post by:
Hi all, I'm working on an assignment where I have to implement a try/finally using C macros. The assignment should be able to work as follows: void foo() { try_point tp1; ...
80
by: pereges | last post by:
Hello, I have the following structure - typedef struct { double x, y, z; }vector; In certain places, I could avoid triplification of code by using an array instead of x, y, z. For eg:
2
by: emitrax | last post by:
Hi there, is there any difference between using bit fields structure and plain variable plus macros for dealing with bits? Let's say I have a two bytes divided as follow 0 - 2: level 3 -...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.