#include <stdio.h>
#define N 5
void mult (int v[], int N, int g);
int main() {
int i, v[N], x;
for (i=0; i<N; i++){
printf("Inserirt value in %d position: ", i+1);
scanf("%d", &v[i]);
}
printf("Insert value to moltiply each vector v
我正在尝试编写宏,它同时定义两个紧密连接的类,但我做不到。这是我的代码:
#ifndef SIGNALS_HPP
#define SIGNALS_HPP
#include <unordered_set>
#include <cstdio>
/**
* Macro defines pair of classes, sender and receiver. When one of them is destroyed,
* all it's connections are dully unconnected.
*
* EXAMPLE:
*
这个程序的输出为5,但是在替换了所有宏之后,就会产生--5。这将导致编译错误,试图减少5。但是它编译和运行都很好。
#include <stdio.h>
#define A -B
#define B -C
#define C 5
int main()
{
printf("The value of A is %d\n", A);
return 0;
}
为什么没有错误?
当C中的宏和函数发生冲突时,会抛出什么错误?这是一个宏处理器错误,还是由于某些语言冲突而发生此错误?
例如,在此代码中:
#include <stdio.h>
#define MAX(i, j) (i>j)? i : j
int MAX(int i, int j){
return (i>j) ? i : j;
}
int main(){
int max = MAX(5, 7);
printf("%d",max);
return 0;
}
程序会抛出编译时错误。但是我不知道这是不是因为某种语言冲突或者宏扩展错误或者其他什么原因。
我写了这段代码:
#include <stdio.h>
#define fctrl(N) ( (N==1)? (N) : (N*fctrl(N-1)) )
int main()
{
int m,n=7;
m = fctrl(n);
printf("fctrl is %d\n",m);
return 0;
}
在编译过程中,我得到了以下错误:
/tmp/ccRODXnZ.o: In function `main':
/home//Desktop/fctrl/fctrl.c:8: undefined reference to
来自 of function表单:
像quote', but preferred for objects which are functions. In byte compilation,函数一样,使它的参数被编译。“引号”不能那么做。
因此,可以执行#'(lambda ...)来启用lambda表单的字节编译。
另一方面,,这不再是必要的。
lambda表单还有另一个效果:它使用function作为子例程,告诉Emacs计算器和字节编译器它的参数是一个函数。
..。以下表格均相等:
(lambda (x) (* x x))
(function (lamb