我正试图构建sysrepo库https://github.com/sysrepo/sysrepo作为对travis ci的依赖,并且遇到位字段的问题。当我在14.04或16.04版本的ubuntu虚拟机上进行安装时,我没有遇到这个问题,我很困惑为什么在使用travis ci时会出现这个问题。安装所有内容的生成脚本如下:

#!/bin/bash
set -e
#this script installs sysrepo and all of its dependencies.
INSTALL_PREFIX_DIR=$HOME/local
export PKG_CONFIG_PATH=$INSTALL_PREFIX_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
export CC=gcc

sudo apt-get update -qq
sudo apt-get install -y cmake libev-dev libavl-dev
sudo apt-get install -y build-essential
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALL_PREFIX_DIR/lib

GODIR=$PWD
cd $HOME

if [ ! -d "$INSTALL_PREFIX_DIR/lib" ]; then

  # libyang
  git clone https://github.com/CESNET/libyang.git
  cd libyang ; mkdir build ; cd build
  cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX_DIR  -DCMAKE_BUILD_TYPE=Debug -DENABLE_BUILD_TESTS=OFF ..
  make -j2 && sudo make install
  cd ../..

  # protobuf
  git clone https://github.com/google/protobuf.git
  cd protobuf
  ./autogen.sh && ./configure --prefix=$INSTALL_PREFIX_DIR
  sudo make -j2
  sudo make install
  cd ..

  # protobuf-c
  git clone https://github.com/protobuf-c/protobuf-c.git
  cd protobuf-c
  ./autogen.sh && ./configure --prefix=$INSTALL_PREFIX_DIR
  sudo make -j2
  sudo make install
  cd ..

else
    echo "Using cached libraries from $INSTALL_PREFIX_DIR"
fi

echo "$INSTALL_PREFIX_DIR/lib" | sudo tee /etc/ld.so.conf.d/sysrepolibs.conf
sudo ldconfig

#sysrepo
git clone https://github.com/sysrepo/sysrepo.git
cd sysrepo
mkdir build ; cd build ;
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=$HOME/local ..
make
sudo make install
cd ../..

sudo ldconfig

#start sysrepo
sudo sysrepod -d -l4 &> sysrepod.log &

cd $GODIR

这是在travis上的before_脚本中调用的,除了我收到以下警告之外,一切正常:
 [  3%] Building C object src/CMakeFiles/COMMON.dir/common/sysrepo.pb-c.c.o
    [  5%] Building C object src/CMakeFiles/COMMON.dir/common/sr_common.c.o
    In file included from /home/travis/local/include/libyang/libyang.h:20:0,
                     from /home/travis/sysrepo/src/common/sr_utils.h:36,
                     from /home/travis/sysrepo/src/common/sr_common.h:44,
                     from /home/travis/sysrepo/src/common/sr_common.c:28:
    /home/travis/local/include/libyang/tree_schema.h:241:5: warning: type of bit-field ‘type’ is a GCC extension [-Wpedantic]
         uint8_t type:1;                  /**< 0 - structure type used to distinguish structure from ::lys_submodule */
         ^
    /home/travis/local/include/libyang/tree_schema.h:242:5: warning: type of bit-field ‘version’ is a GCC extension [-Wpedantic]
         uint8_t version:4;               /**< yang-version:
         ^
    /home/travis/local/include/libyang/tree_schema.h:246:5: warning: type of bit-field ‘deviated’ is a GCC extension [-Wpedantic]
         uint8_t deviated:2;

我不是构建C项目的专家,但有什么帮助会非常感谢?

最佳答案

C只支持int、unsigned int和布尔作为位字段的类型。其他类型是实现定义的。
使用标志Wpedantic,编译器将严格遵循标准,如果您使用某些实现定义的功能或扩展,编译器将尝试发出警告。
删除标志-Wpedantic。

关于c - 尝试构建库并收到以下警告:warning:位字段的类型'type'是GCC扩展名[-Wpedantic] uint8_t type:1;,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40377121/

10-11 23:55