Connection to C-language macro function parameters

Source: Internet
Author: User

#include <stdio.h> #define CALCULATE_MAX (b) a>b? A:b#define Calculate_min (A, b) a<b?        A:b#define Calculate (a,b,name) calculate_# #NAME (A, b) int main (void) {printf ("%d\n", Calculate (5,8,max)); return 0;}

When using macro functions or macro functions, pay attention to the following points:

(1) The parameters of the macro function do not have a type, the preprocessor is only responsible for the formal substitution, and does not do parameter type checking, so you should take extra care when you pass the parameter.

(2) The macro function definition should pay attention to the format, especially the parentheses.


This article is from the "canvas shoes can walk the cat step" blog, please be sure to keep this source http://9409270.blog.51cto.com/9399270/1863774

Connection to C-language macro function parameters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.