UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How can type-insensitive macros be created?

Asked by Last Modified  

Follow 0
Answer

Please enter your answer

Computer Wizard

A type-insensitive macro is a macro that performs the same basic operation on different data types. This task can be accomplished by using the concatenation operator to create a call to a type-sensitive function based on the parameter passed to the macro. The following program provides an example: #include...
read more
A type-insensitive macro is a macro that performs the same basic operation on different data types. This task can be accomplished by using the concatenation operator to create a call to a type-sensitive function based on the parameter passed to the macro. The following program provides an example: #include #define SORT(data_type) sort_ ## data_type void sort_int(int** i); void sort_long(long** l); void sort_float(float** f); void sort_string(char** s); void main(void); void main(void) { int** ip; long** lp; float** fp; char** cp; ... sort(int)(ip); sort(long)(lp); sort(float)(fp); sort(char)(cp); ... } This program contains four functions to sort four different data types: int, long, float, and string (notice that only the function prototypes are included for brevity). A macro named SORT was created to take the data type passed to the macro and combine it with the sort_ string to form a valid function call that is appropriate for the data type being sorted. Thus, the string sort(int)(ip); translates into sort_int(ip); after being run through the preprocessor. read less
Comments

VBA/Excel/Access/SQL Server

Similar to polymorphism in c++ if you are familiar to this. A type insensitive macro is a macro that perform the same base operation on different data type.Have common name but different signature. This task can be accomplished by using the concatenation operator to create a call to a type sensitive...
read more
Similar to polymorphism in c++ if you are familiar to this. A type insensitive macro is a macro that perform the same base operation on different data type.Have common name but different signature. This task can be accomplished by using the concatenation operator to create a call to a type sensitive function based on the parameter passed to the macro/program/module/function. read less
Comments

By using concatenation operator we can create a type-insensitive macro. For Example: #define ADD(data_type) add_ ## data_type void add_int(int i, int j) { int h = i+j; printf("%d",h); } void add_float(float k, float l) { float m = k+l; printf("%f",m); } void main(void) { int...
read more
By using concatenation operator we can create a type-insensitive macro. For Example: #define ADD(data_type) add_ ## data_type void add_int(int i, int j) { int h = i+j; printf("%d",h); } void add_float(float k, float l) { float m = k+l; printf("%f",m); } void main(void) { int a=1, b=1; float c=1.1, d=1.1; ADD(int)(a,b); ADD(float)(c,d); } here, ADD(int)(a,b); translates into add_int(a,b); read less
Comments

Computer & Maths Professor

A type-insensitive macro is a macro that performs the same basic operation on different data types. This task can be accomplished by using the concatenation operator to create a call to a type-sensitive function based on the parameter passed to the macro.
Comments

View 2 more Answers

Related Questions

Which should I learn first, C or UNIX?
As you know C is a programming language and UNIX is Operating System if you want to grow your career as Programmer/Developer than go for C/C++ programming as it is very basic programming languages and...
Tushar
0 0
5
The object file is in binary code, and the machine understands the binary language. So why object files are not executed?
Object files are sources compiled into binary machine language, but they do not have library files, so they are not executed.
Dhruvil
0 0
9
How do I print \n in C or C++ programming?
void main () { printf(" "); getch(); }
Supriyo
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Datatypes in C Language
Data types in C Language Data types specify how we enter data into our programs and what type of data we enter. C language has some predefined set of data types to handle various kinds of data that...

INTRODUCTION TO PROGRAMMING LANGUAGES
Language is a medium for communication. If we want to perform anything with another person, we can know the human language as a human being. Similarly, if we want to perform anything with a computer, we...

Internet of Things, Social Media Becoming Part of E-Discovery Landscape
The days when e-discovery consisted of handing over copies of e-mails to address Freedom of Information Act (FOIA) requests, compliance regulations or other legal obligations are over. Now, it's just as...

An Interesting discussion about malloc( ) and calloc( )
What are malloc( ) and calloc( )? Simply putting they are the predefined functions in C language. Malloc( ) and calloc( ) are two such functions which are used for more or less identical purpose and...

Some interview questions for freshers on C language
Q1. What are the two forms of #include? There are two variants of #include. The one is #include and the other one is #include”file”. In general the first form that is #include is used to...

Recommended Articles

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

Read full article >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more