Coding Standards for pure C (not C++)

前端 未结 11 1960
盖世英雄少女心
盖世英雄少女心 2020-12-12 14:17

I come from a java background (from my CS classes) and a semester of C++. I am just finishing up a OpenCV project for my Co-Op that\'s in pure C, so I\'m a bit late in aski

11条回答
  •  猫巷女王i
    2020-12-12 15:03

    Good news is that you can program in a semi-object oriented fashion in C. You can protect data, expose access functions, etc. It may not have all of the fanciness of C++, but from what I have seen of other people's C++ code, many people do not use the fanciness anyway. In other words, people write C code inside a class, where in C you'd write the same code without the class container.

    First, read a book on C programming and style, K&R is fine. Second, I'd recommend checking out CERT Programming Standard. Even though this site is primarily focused on "Secure" coding standards, much of the content here is general code quality standards everyone should follow. Doing the things mentioned here will improved your quality, eliminate pesky bugs, and as a side effect, make your code more secure.

提交回复
热议问题