什么是一个宏观和C中的函数之间的区别? [英] What is the difference between a macro and a function in C?

查看:148
本文介绍了什么是一个宏观和C中的函数之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是宏观,并在 C 函数之间的区别?请告诉我一个应用程序,我可以使用宏和功能?

What is the difference between a macro and a function in C? Please tell me one application where I can use macros and functions?

推荐答案

基本的区别是,函数编译和宏是preprocessed。当您使用函数调用将被翻译成所有这些堆栈操作ASM CALL来传递参数和返回值。当您使用宏,C preprocessor将翻译使用宏,比编译所有字符串。

The basic difference is that function is compiled and macro is preprocessed. When you use a function call it will be translated into ASM CALL with all these stack operations to pass parameters and return values. When you use a MACRO, C preprocessor will translate all strings using macro and than compile.

使用宏减去的是,他们隐藏实现。它的方式很难找到的bug,如果有一个。

Minus of using macros is that they hide implementation. Its way harder to find bug if have one.

这篇关于什么是一个宏观和C中的函数之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆