Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: niffiwan on July 11, 2013, 10:04:52 pm

Title: Static Code Analysis: Valve Style
Post by: niffiwan on July 11, 2013, 10:04:52 pm
This is an interesting read that I stumbled across today, there's some tips in there for VS, gcc & clang.

http://randomascii.wordpress.com/2013/06/24/two-years-and-thousands-of-bugs-of-static-analysis/
Title: Re: Static Code Analysis: Valve Style
Post by: pecenipicek on July 12, 2013, 07:43:38 am
well, i've ran fso antipodes r9580 debug build compilation through it. have fun with the results: download (http://www.egzodus.com/dir/clang-analysis-fso-ant-r9580.7z)

beware, the uncompressed folder is 844MB

for the record my system is 3.8.13-gentoo, x64, running on a core i7 860, 8 gigs of ram, and this is my trivial compile script

Code: [Select]
#!/bin/bash
CC="clang"
CXX="clang++"
CFLAGS="-march=native -pipe"
CXXFLAGS="${CFLAGS}"
cd ~/dev/FSO_Antipodes

make clean
scan-build -v -o ~/temp/clangOut ./configure CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" --enable-debug #CC=${CC} CXX=${CXX}
scan-build -v -o ~/temp/clangOut make -j8

also, FSO compiles fine with clang, but i havent tried running anything with it yet.

(if its useful to anyone, yay, if not, oh well)

[edit] running a recompile now, since i missed nice little detail about the compile script which resulted in CXXFLAGS not being applied at all. if my explicit declaration of -std=c++0x is slightly retarded, call me out on it.
[edit 2]yeah, it doesnt compile with the -std=c++0x, and i'm not about to go debug it specifically. the stuff that i linked for download should be accurate for a normal compile without the -std=c++0x option.
[edit 3]fixed the download so that it actually works.
Title: Re: Static Code Analysis: Valve Style
Post by: Phantom Hoover on July 12, 2013, 08:04:08 am
the things people will do to avoid using a language with a proper type system
Title: Re: Static Code Analysis: Valve Style
Post by: The E on July 12, 2013, 08:07:45 am
the things people will do to avoid using a language with a proper type system

Please elaborate. C/C++ seem to have a rather solid type system already (unlike, say, Lua).
Title: Re: Static Code Analysis: Valve Style
Post by: pecenipicek on July 12, 2013, 03:01:34 pm
Here's (http://www.egzodus.com/dir/clang-analysis-fso-trunk-r9720.7z) a proper package containing the analysis for trunk r9720.

I should've looked at the latest commit log for antipodes... :p
Title: Re: Static Code Analysis: Valve Style
Post by: Phantom Hoover on July 12, 2013, 03:54:22 pm
the things people will do to avoid using a language with a proper type system

Please elaborate. C/C++ seem to have a rather solid type system already (unlike, say, Lua).

By which you mean they have an (explicit) type system; which, as far as the programming mainstream goes, is about the furthest you'll go. But if you look at something like e.g. Haskell's type system, it's worlds ahead of C's crude byte-counter, and there's stuff that's even more sophisticated still (https://en.wikipedia.org/wiki/Dependent_type), and in which something as primitive as printf would be completely crazy.