0

I am peeking through the code of torsocks where as you'll notice, the .travis.yml file instructs Travis CI to test against both clang and gcc.

compiler:
  - clang
  - gcc

I'm still learning and this caught my attention. Why both? Why not just one or the other? Thanks!

Alex V
  • 111
  • 4

1 Answers1

3

The two compilers have different quirks, and different levels of support for the various C and C++ standards. Code that compiles for one may trigger an error on the other. If you want folks to be able to build your software using either compiler, you have to test that you've accomodated for the differences between the compilers.

Charles E. Grant
  • 16,612
  • 1
  • 46
  • 73
  • Thanks, I guess that was pretty obvious in retrospect haha. – Alex V Dec 14 '18 at 00:55
  • It also effectively prevents using compiler-specific features that would limit portability. – Alex Reinking Dec 14 '18 at 01:43
  • 1
    @AlexReinking actually you can still take advantage of compiler specific features, but you have to have a more elaborate build, and you may need to use the preprocessor to support alternative blocks of code for each compiler. – Charles E. Grant Dec 14 '18 at 01:51