小编Jef*_*sey的帖子

clang和gcc之间的行为差​​异?

我正在编写一个C函数来模拟给定地址跟踪的缓存.使用gcc(真正的铿锵)在我的mac上编译时,该函数按预期工作.gcc --version在我的Mac上返回:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Run Code Online (Sandbox Code Playgroud)

当我使用gcc在linux上编译相同的程序时,返回是关闭的,我的程序中的eC&hC(缓存逐出计数器和命中计数器)是数十万,当它们应该低于10.当键入gcc时 - -version在linux机器上,它返回:

gcc(Ubuntu 4.9.3-8ubuntu2~14.04)4.9.3

这是程序:

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>
    #include <limits.h>
    #include <getopt.h>
    #include "cachelab.h"

    typedef struct{
        int v;
        int t;
        int LRU;
    } block;

    typedef struct{
        block *blocks;
    } set;

    typedef struct{
        set *sets;
    } cache;

    void simulate(int s, int E, int b, char* file, int* hC, int* mC, int* eC)
    {
        int numSets = (1 << s);
        char operation;
        int …
Run Code Online (Sandbox Code Playgroud)

c linux macos gcc compiler-errors

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

标签 统计

c ×1

compiler-errors ×1

gcc ×1

linux ×1

macos ×1