mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r23941) -Add: support for clang
This commit is contained in:
parent
f4de9b8a37
commit
b5525fd33d
56
config.lib
56
config.lib
@ -1159,11 +1159,11 @@ make_compiler_cflags() {
|
||||
if [ -z "$first_time_icc_check" ]; then
|
||||
first_time_icc_check=no
|
||||
if [ $cc_version -lt 90 ]; then
|
||||
log 1 "WARNING: you seem to be using very old version of ICC"
|
||||
log 1 "WARNING: you seem to be using a very old version of ICC"
|
||||
log 1 "WARNING: OpenTTD hasn't been tested with this version"
|
||||
sleep 5
|
||||
elif [ $cc_version -lt 120 ]; then
|
||||
log 1 "WARNING: you seem to be using unsupported ICC version"
|
||||
log 1 "WARNING: you seem to be using an unsupported ICC version"
|
||||
log 1 "WARNING: ICC older than 12.0 is known to fail to compile OpenTTD"
|
||||
sleep 5
|
||||
fi
|
||||
@ -1236,6 +1236,58 @@ make_compiler_cflags() {
|
||||
features="$features lto"
|
||||
fi
|
||||
fi
|
||||
elif [ `basename $1 | grep 'clang'` ]; then
|
||||
# Enable some things only for certain clang versions
|
||||
cc_version="`$1 -v 2>&1 | head -n 1 | sed s@[^0-9]@@g | cut -c 1-2`"
|
||||
|
||||
# aliasing rules are not held in openttd code
|
||||
flags="$flags -fno-strict-aliasing"
|
||||
|
||||
# -W alone doesn't enable all warnings enabled by -Wall; on the other hand,
|
||||
# -Weverything enables too many useless warnings that can't be disabled (as of 3.0)
|
||||
flags="$flags -Wall -W"
|
||||
|
||||
# warning: unused parameter '...'
|
||||
flags="$flags -Wno-unused-parameter"
|
||||
|
||||
# warning: expression result unused
|
||||
flags="$flags -Wno-unused-value"
|
||||
|
||||
# warning: multi-character character constant
|
||||
flags="$flags -Wno-multichar"
|
||||
|
||||
# warning: explicitly assigning a variable of type '...' to itself
|
||||
# it happens when using the FOR_ALL_WINDOWS_FROM_BACK_FROM macro
|
||||
flags="$flags -Wno-self-assign"
|
||||
|
||||
if [ "$cc_version" -lt "30" ]; then
|
||||
# warning: equality comparison with extraneous parentheses
|
||||
flags="$flags -Wno-parentheses"
|
||||
# warning: operands of ? are integers of different signs: 'unsigned int' and 'int'
|
||||
flags="$flags -Wno-sign-compare"
|
||||
fi
|
||||
|
||||
if [ "$cc_version" -ge "30" ]; then
|
||||
# warning: equality comparison with extraneous parentheses
|
||||
# this warning could be useful, but it warns about code in squirrel
|
||||
flags="$flags -Wno-parentheses-equality"
|
||||
fi
|
||||
|
||||
if [ "$with_ccache" != "0" -o "$with_distcc" != "0" ]; then
|
||||
# ccache and distcc run separate preprocess and compile passes,
|
||||
# both are fed with the same CFLAGS. Unfortunately, clang
|
||||
# complains about -I when compiling preprocessed files:
|
||||
# "clang: warning: argument unused during compilation: '-I /usr/include'"
|
||||
flags="$flags -Qunused-arguments"
|
||||
fi
|
||||
|
||||
if [ "$enable_assert" -eq "0" ]; then
|
||||
# do not warn about unused variables when building without asserts
|
||||
flags="$flags -Wno-unused-variable"
|
||||
fi
|
||||
|
||||
# rdynamic is used to get useful stack traces from crash reports.
|
||||
ldflags="$ldflags -rdynamic"
|
||||
else
|
||||
# Enable some things only for certain GCC versions
|
||||
cc_version=`$1 -dumpversion | cut -c 1,3`
|
||||
|
@ -1,5 +1,5 @@
|
||||
OpenTTD readme
|
||||
Last updated: 2012-02-04
|
||||
Last updated: 2012-02-12
|
||||
Release version: 1.2.0-beta4
|
||||
------------------------------------------------------------------------
|
||||
|
||||
@ -501,6 +501,8 @@ The following compilers are known to compile OpenTTD:
|
||||
Versions 4.4 - 4.6 give bogus warnings about freeing non-heap objects.
|
||||
Versions 4.5 and later give invalid warnings when lto is enabled.
|
||||
- Intel C++ Compiler (ICC) 12.0.
|
||||
- Clang/LLVM 2.9 - 3.0
|
||||
Version 2.9 gives bogus warnings about code nonconformity.
|
||||
|
||||
The following compilers are known not to compile OpenTTD:
|
||||
- Microsoft Visual C++ (MSVC) 2003 and earlier.
|
||||
@ -510,7 +512,7 @@ The following compilers are known not to compile OpenTTD:
|
||||
Version 10.0 and earlier fail a configure check and fail with recent system
|
||||
headers.
|
||||
Version 10.1 fails to compile station_gui.cpp.
|
||||
Version 11.1 fails with internal error when compiling network.cpp.
|
||||
Version 11.1 fails with an internal error when compiling network.cpp.
|
||||
- Clang/LLVM 2.8 and earlier.
|
||||
- (Open) Watcom.
|
||||
|
||||
|
@ -107,7 +107,11 @@ DEFINE_POOL_METHOD(inline void *)::AllocateItem(size_t size, size_t index)
|
||||
assert(sizeof(Titem) == size);
|
||||
item = (Titem *)this->alloc_cache;
|
||||
this->alloc_cache = this->alloc_cache->next;
|
||||
if (Tzero) MemSetT(item, 0);
|
||||
if (Tzero) {
|
||||
/* Explicitly casting to (void *) prevets a clang warning -
|
||||
* we are actually memsetting a (not-yet-constructed) object */
|
||||
memset((void *)item, 0, sizeof(Titem));
|
||||
}
|
||||
} else if (Tzero) {
|
||||
item = (Titem *)CallocT<byte>(size);
|
||||
} else {
|
||||
|
@ -2100,11 +2100,18 @@ void NetworkPrintClients()
|
||||
{
|
||||
NetworkClientInfo *ci;
|
||||
FOR_ALL_CLIENT_INFOS(ci) {
|
||||
IConsolePrintF(CC_INFO, _network_server ? "Client #%1d name: '%s' company: %1d IP: %s" : "Client #%1d name: '%s' company: %1d",
|
||||
if (_network_server) {
|
||||
IConsolePrintF(CC_INFO, "Client #%1d name: '%s' company: %1d IP: %s",
|
||||
ci->client_id,
|
||||
ci->client_name,
|
||||
ci->client_playas + (Company::IsValidID(ci->client_playas) ? 1 : 0),
|
||||
_network_server ? (ci->client_id == CLIENT_ID_SERVER ? "server" : NetworkClientSocket::GetByClientID(ci->client_id)->GetClientIP()) : "");
|
||||
ci->client_id == CLIENT_ID_SERVER ? "server" : NetworkClientSocket::GetByClientID(ci->client_id)->GetClientIP());
|
||||
} else {
|
||||
IConsolePrintF(CC_INFO, "Client #%1d name: '%s' company: %1d",
|
||||
ci->client_id,
|
||||
ci->client_name,
|
||||
ci->client_playas + (Company::IsValidID(ci->client_playas) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ typedef bool (ScriptModeProc)();
|
||||
*/
|
||||
class ScriptObject : public SimpleCountedObject {
|
||||
friend class ScriptInstance;
|
||||
friend class ScriptController;
|
||||
protected:
|
||||
/**
|
||||
* A class that handles the current active instance. By instantiating it at
|
||||
|
@ -123,7 +123,7 @@ ScriptVehicleList_DefaultGroup::ScriptVehicleList_DefaultGroup(ScriptVehicle::Ve
|
||||
const Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->owner == ScriptObject::GetCompany() && v->IsPrimaryVehicle()) {
|
||||
if (v->type == vehicle_type && v->group_id == ScriptGroup::GROUP_DEFAULT) this->AddItem(v->index);
|
||||
if (v->type == (::VehicleType)vehicle_type && v->group_id == ScriptGroup::GROUP_DEFAULT) this->AddItem(v->index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ static char *FormatNumber(char *buff, int64 number, const char *last, const char
|
||||
quot = num / divisor;
|
||||
num = num % divisor;
|
||||
}
|
||||
if (tot |= quot || i >= max_digits - zerofill) {
|
||||
if ((tot |= quot) || i >= max_digits - zerofill) {
|
||||
buff += seprintf(buff, last, "%i", (int)quot);
|
||||
if ((i % 3) == thousands_offset && i < max_digits - 1 - fractional_digits) buff = strecpy(buff, separator, last);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user