0
$\begingroup$

Do we consider functions like printf part of C language even if it's not a keyword in it.

$\endgroup$
4
$\begingroup$

The “C programming language“ is defined by a document that defines the syntax and the semantics of programs, and the C standard library. So both are part of the “C programming language”.

However, in CS the term “language” is used in a different way, as a set of strings. You can define a language based purely on the syntax In the C Standard document - that allows you to distinguish between strings that are formally in the language and those that are not, but you still have no clue what a program would do.

You can also incorporate some semantic rules, so that for example int a[-10] or int i = "String" are not considered to be part of the language.

$\endgroup$
2
$\begingroup$

Yes, absolutely.

For a start, they are the same document. The C programming language standard incorporates the standard library.

But even more than this, a C compiler is allowed to generate calls to the C standard library. This is obvious in the case of C++ (e.g. std::unexpected), but even in C, a compiler is free to compile a large struct assignment as a call to memcpy if it wants to. Most C compilers have a way to turn this off.

$\endgroup$
6
  • $\begingroup$ I would disagree. From programming language perspective printf or any standard library function is a function like any other. $\endgroup$
    – dumpram
    Aug 16 '20 at 9:19
  • 2
    $\begingroup$ @dumpram: The official C definition incorporates the standard library into the language definition. How can you argue against that? $\endgroup$ Aug 16 '20 at 9:26
  • $\begingroup$ If standard library is not provided to the linker, C program which uses standard library functions will not link. $\endgroup$
    – dumpram
    Aug 16 '20 at 10:15
  • 1
    $\begingroup$ longjmp is most definitely not a “function like any other”. And a program trying to define printf while including studio.h is not a valid C program. In addition, the Standard Library defines types and macros. $\endgroup$
    – gnasher729
    Aug 16 '20 at 10:41
  • $\begingroup$ @dumpram: You can hack anything together, but then you can’t call it C language. $\endgroup$
    – gnasher729
    Aug 16 '20 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.