小编Joh*_*ohn的帖子

在VS2010 C++中解析"找到'{'在文件范围(缺少函数头?)"

我正在使用Visual Studio 2010 Express,我收到文件test.h的以下错误,当编译输出时:

test.h(4): error C2061: syntax error : identifier 'test'
test.h(4): error C2059: syntax error : ';'
test.h(4): error C2449: found '{' at file scope (missing function header?)
test.h(18): error C2059: syntax error : '}'
Run Code Online (Sandbox Code Playgroud)

文件test.h描述如下:

#ifndef TEST_H
#define TEST_H

class test {
    int a; 
    int b; 
public:        
    test(int a, int b) { 
        this->a = a;
        this->b = b;
    }

    int add() { 
        return 0;
    }
};

#endif
Run Code Online (Sandbox Code Playgroud)

VS2010项目中的另一个文件是test.c,它是:

#include "test.h"

int main(int argc, char** argv) {
    return …
Run Code Online (Sandbox Code Playgroud)

c++ visual-studio-2010

2
推荐指数
1
解决办法
3743
查看次数

makefile自动执行操作

我编写了简单的代码*make_test*来测试makefile的功能.文件夹结构如下:

  1. include文件夹包含maths.h

    float add(float a, float b) 
    {
        return a+b;
    }
    
    Run Code Online (Sandbox Code Playgroud)
  2. 主文件包含以下代码:

    # include <stdio.h>
    # include <include/maths.h> 
    
    int main(int argc, char** argv) 
    {
        float a=1; 
        float b=4; 
    
        printf("%f + %f = %f\n", a, b, add(a, b));
        return 0;
     }
    
    Run Code Online (Sandbox Code Playgroud)
  3. makefile包含以下内容:

    IDIR = -I.
    DEPS = ./include/maths.h
    CC= gcc -Wall -g $(IDIR)
    
    program: make_test.o
    
    %.o: test/%.c $(DEPS)
        @echo "Rule 1 was called"
        $(CC) -o $@ $<
    
    %.o: test/%.c $(DEPS)
        @echo "Rule 2 was called"
        $(CC) -o $@ $<
    
    %.o: …
    Run Code Online (Sandbox Code Playgroud)

c makefile gnu-make

1
推荐指数
1
解决办法
78
查看次数

通过 kubectl 获取正在运行的容器的快照

是否可以使用 pod 内运行的容器拍摄图像或快照kubectl

通过docker,可以使用docker commit创建容器映像的命令,我们可以从中生成更多容器。我想了解我们是否可以做类似的事情kubectl

kubernetes kubectl

1
推荐指数
1
解决办法
1053
查看次数

标签 统计

c ×1

c++ ×1

gnu-make ×1

kubectl ×1

kubernetes ×1

makefile ×1

visual-studio-2010 ×1