How to implement typeof operator in C

Is typeof operator available in C. If yes how to implement it. Or is there a header file I must use? I am getting the following error when I try to use the typeof statement

  • Undeclared function 'typeof' (did you mean feof?); assuming extern returning int.

Answers


C is a much lower level language than Python with very little magic. It is good for low level tasks - the reference implementation of Python is written in C ...

Even if recent C version are less tolerant than good old K&R C from the 1970s (*), the rule is mainly : if the programmer knows it, there's no use the compiler care's for it. Examples :

  • arrays : the programmer shall care for the size, the compiler only cares for the starting address
  • variable type : the programmer should know, compiler only cares for it at compile time, but does not store information for run time

(*) there are indeed rules enforced by the compiler, but mainly at compile time : at run time the program is stripped down to a minimum


Need Your Help

Creating an XCode project from the command line?

xcode command-line project creation

I get a new project coming across my desk on an hourly basis. They all adhere to a very strict format, so it isn't terribly difficult to create a new project from scratch every time, but it is som...

How to group documents by month in mongodb?

mongodb mongodb-query aggregation-framework

I have a collection of transaction data in mongodb, like this: