Will a C program compile in a C++ workspace? -
i'm new c/c++ , have downloaded codelite ide (any other suggestions free ones welcome). intend write c program, gives me option create c++ workspace. can write c in workspace same?
it depends on ide, compiler (which invoked ides compile code, , [not always] not part of ide), , type of code write.
practically, quite few c++ compilers have "c mode" - example, command line switches or other settings may configurable through ide - compile c. you'll need read compiler , ide documentation. bear in mind compilers, in c mode, support c++ features not valid in c (and reverse true).
it depends on sort of c code intend write, , how know features of c not part of c++, , vice versa.
but, yes, general rule can write c program in c++ workspace. aware of concerns above when doing so.
also, don't surprised when proudly show of lovingly crafted code seasoned c or c++ developer, informed writing hybrid of c , c++. unfortunately, writing hybrid of c , c++ considered poor form both c , c++ developers - because code work compilers , fail others. many compiler vendors intermix c , c++ in documentation, , learning material (introductory texts, etc) same. if writing c code in (suitably configured) c++ environment, there fair chance compiler won't complain code doing that. isn't problem inherent writing c in c++ environment - many vendors of c compilers support c++ features extension, , vice versa - phenomenon more encounter if write c code in c++ environment, unless go out of way learn differences between standard c , standard c++ independently of compiler , compiler documentation.
i've lost track of number of beginners end writing code hybrid of c , c++ (e.g. using c++-specific features while believing writing c, or vice versa). have code break when build different compiler (or, worse, update of compiler).
if intend write code includes mix of c , c++ (by mean pure c functions interfacing pure c++ functions, not hybrid mentioned above), need allow orchestration of build process - particularly linking - controlled c++ settings, if compilation settings particular files mean compiled c or c++.
Comments
Post a Comment