How to structure a C program effectively

后端 未结 7 1460
独厮守ぢ
独厮守ぢ 2020-12-24 12:01

Let me first say that I\'ve got a fair amount of experience in both C and C++. However, I\'m starting a new project in C and I\'ve been working in object-oriented languages

7条回答
  •  一个人的身影
    2020-12-24 12:41

    I agree with the suggestions above. You are doing it the best way .. if you want to program in C.

    Of course, you could write a pre-processor to automatically generate these declarations and things for you .. maybe use a "Class" declaration ... put the functions you want to be member functions inside the class .. etc.

    But what we've got here is a simple C++ to C compiler. Why not just program in C++, use a real C++ compiler, use clean interfaces, and just link the C++ code with the C code? What is the reason that you need to code in C vs. C++ anyways? Or if you need to, generate C code from the compiler and compile the output C code together with whatever else you need.

提交回复
热议问题