In spite of having read K&R, and having even taught C classes, I find myself embarrassingly unable to fully understand what one might call "modern" C.
There seems to be many unwritten conventions in modern programming that, as far as I know, aren't documented anywhere.
Take, for example, the SQLite source code. In it I find for instance:
SQLITE_API int sqlite3_close(sqlite3 *);
What does SQLITE_API
stand for? How is this even syntactically correct?
Or this:
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
Is there an accepted convention somewhere on when to prefix macros with underscores? Sometimes I see macros prefixed with two underscores.
Or what about the use of fixed-size types, such as uint32
and so forth. When should one use this practice, and when not? What about the new-ish bool
type, when should it be preferred over simple ints?
These are some of the questions I pose myself when I read other people's source code. Is there a reference somewhere that might help me answer these questions?
At FavTutor, we have expert tutors in C programming who help you accomplish impeccable quality assignments well within the required deadline. Moreover, you can also connect with our tutors 24/7 through chat or email.
C might be old, but it is definitely relevant in 2022 and will likely remain so. The simplicity of C provides you with a perfect gateway into the programming world. It helps you understand the detailed implementation of any algorithm.
The C programming language has been alive and kicking since 1972, and it still reigns as one of the fundamental building blocks of our software-studded world.
SQLITE_API
in code like this is very likely a preprocessor define, that worries about exposing the call in e.g. a DLL library build. That's pretty common.
If it's all upper case in C, chances are it's a preprocessor symbol, and a good idea is often to run the game through the preprocessor and read what comes out.
Afaik GNU coding standards are under constant revision/update so might be a good snapshot of 'modern' style.
http://www.gnu.org/prep/standards/
Re: specifically single or double undercores, in my experience and from what I often read; it's grossly accepted safer to avoid double underscore prefixes as these are usually 'reserved' for framework/system/compiler-specific and compiler-related elements, thus macros intended soley for use within the module/package/unit/project they are defined should avoid being undescore-prefixed at all.
Most institions have their own language coding standards and guidelines which can vary quite significantly. As ever, consistency is key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With