該当のソースコード
C++
1 2/*************************************************************************** 3 4 file : portability.h 5 created : Fri Jul 8 15:19:34 CET 2005 6 copyright : (C) 2005 Bernhard Wymann 7 email : berniw@bluewin.ch 8 version : $Id: portability.h,v 1.2.2.3 2012/05/19 14:47:30 berniw Exp $ 9 10 ***************************************************************************/ 11 12/*************************************************************************** 13 * * 14 * This program is free software; you can redistribute it and/or modify * 15 * it under the terms of the GNU General Public License as published by * 16 * the Free Software Foundation; either version 2 of the License, or * 17 * (at your option) any later version. * 18 * * 19 ***************************************************************************/ 20 21#ifndef _TORCS_PORTABILITY_H_ 22#define _TORCS_PORTABILITY_H_ 23 24#include <stdlib.h> 25#include <cstring> 26 27#ifdef WIN32 28#define HAVE_CONFIG_H 29#endif 30 31#ifdef HAVE_CONFIG_H 32#include <config.h> 33#endif 34 35// Missing strndup, define it here (for FreeBSD). 36// TODO: Move it into library. 37// strndup code provided by Thierry Thomas. 38#ifndef HAVE_STRNDUP 39 40static char *strndup(const char *str, int len) 41{ 42 char *ret; 43 44 if ((str == NULL || len < 0)) { 45 return (NULL); 46 } 47 48 ret = (char *) malloc(len + 1); 49 if (ret == NULL) { 50 return (NULL); 51 } 52 53 memcpy(ret, str, len); 54 ret[len] = '\0'; 55 return (ret); 56} 57 58#endif 59 60 61#ifdef WIN32 62#define snprintf _snprintf 63#if _MSC_VER < 1500 64#define vsnprintf _vsnprintf 65#endif 66#endif 67 68#ifdef WIN32 69#include <math.h> 70 71static float round(float x) 72{ 73 return floor(x+0.5f); 74} 75#endif 76 77#endif // _TORCS_PORTABILITY_H_ 78
発生している問題・エラーメッセージ
torcsというオープンソースコードのカーシュミレーションソフトの プロジェクトファイルをコンパイルしたいと考えています. そこで,上記のコードをVisual studio 2017においてビルドを行うと, static float round(float x)の以下のエラーが発生してしまいます. 対策としてどのようなことが考えられるでしょうか. 宜しくお願い致します. 重大度レベル コード 説明 プロジェクト ファイル 行 抑制状態 エラー C2375 'round': 再定義されています。異なるリンケージです。 olethros c:\users\owner\desktop\torcs-1.3.7\export\include\portability.h 70
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/10 08:42
2018/12/10 08:53
2018/12/10 10:40
2018/12/10 10:51