Does C have templates? [duplicate] - c

This question already has answers here:
Is there an equivalent in C for C++ templates?
(7 answers)
Closed 4 years ago.
I've previously worked with C but I'm still a major newby in general.
Currently I'm working on a little project that involves Parallel Computing and for this we are using the language Cilk+.
My objective is to implement a parallel scan pattern using Cilk+ and I've found this reference to the subject, but I don't understand half of the notations on it.
Does C have templates? I thought only C++ had them.
If yes, how do they work? I've found nothing regarding the subject.
If not, then can someone explain me what line 1 and 5 mean?
Thank you in advance!

C does not have templates. C++ does.
Line 1 is using C++ templates.
Line 5 is not standard C or C++. It is part of the Cilk Plus extension.
If this is a new project, you may way to avoid Cilk Plus. It's officially deprecated. Intel is encouraging everyone to switch to OpenMP or TBB instead.

Related

Popular diagramming tools or methodologies for C [duplicate]

This question already has answers here:
Tools to get a pictorial function call graph of code [closed]
(7 answers)
Closed 9 years ago.
Coming from a java (and other OO backgrond ) i got very cosy in with my objects, natural encapsulation and polymorphism.
All this i expected, the one this i didn't expect was to miss my class diagrams!
When the going gets tough or you start to worry about over coupling it was always my first stop.
But i cant seem to find a C style equivalent (that doesn't date from the mid 90's) diagramming system or utility for C.
have i just missed some thing? is there a hidden gem out there some where?
Even just something to show function calls between files so i can get an idea of whats going on where.
In short: Does any one have a suggestion (or tool) for how to model C file sets? function calls, includes, etc.
Thanks.
You can generate C code from class diagrams with UML applications such as IBM Rational Rhapsody or Eclipse-based open source Topcased.
You can generate call graphs, calling graphs and dependency graphs from C code with doxygen, powered by graphviz.

How does C work? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How was the first compiler written?
I'm asking this as a single question because, essentially what I'm trying to ask is at the bottom how is all of this implemented, here goes:
How was the first C compiler generated, since C compiler is written in C itself then how was the first source of C compiler generated?
Is C written in ASM, how are languages actually designed?, because before we had high level languages the only way to design something was through ASM, even if C is derived from earlier languages, how were they designed? (My clue is ASM)
I'm getting confused as to how does C work down at the bottom. What I'm trying to say is since at the bottom, everything is implemented at the processor by OPcodes. So what my understanding was that C programs are "essentially" translated to Sys Calls which are implemented by the Kernel.
But then how are syscalls implemented? (Do they directly correspond to OPcodes or is there any other layer of abstraction.
How was the first C compiler generated, since C compiler is written in C itself then how was the first source of C compiler generated?
Bootstrapping.

The ambiguity in the outputs of different C compilers [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Undefined Behavior and Sequence Points
Which 'C' compiler gives the logically correct answers... I mean Turbo C older version or the newer one named as Borland cpp 4.5 and above?
The different outputs of the question { int i=5;printf(i++*++i);} made me ask this.
No C compiler will give a correct answer.
The most correct answer would be to detect nonsense of this kind and refuse to compile it with an error message.

Write a compiler from scratch in C [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to code a compiler in C?
How would I start writing a compiler from scratch (no Flex or Bison or Lex or Yacc) in C? I have a language that I wrote an interpreter for, and it's kind of like Forth. Sort of. It takes in symbols and interprets them one at a time, using a stack.
How would I make a compiler?
That wasn't a particularly spammy bit; just to show people the syntax and simplicity.
http://github.com/tekknolagi/StackBased
Simple!
You tokenize the input.
You build a proper representation of it, generally this is an Abstract Syntax Tree, but that is not required.
You perform any tree transformations you may require (optional).
You generate the code by walking the tree.
You link any disparate portions together (optional)
Flex and Bison help with stage 1 and 2, everything else is up to you. If you're still stuck, I suggest going through "Programming Language Pragmatics" or The Dragon Book.

R*-Tree C Implementation? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
C++ R - tree implementation wanted
I've been hunting just about all evening...
Anyone know of a R*-Tree implementation that builds on a modern C compiler?
Thanks,
Chenz
SQLite's R* Tree might interest you. It is under public domain or such free license and builds with gcc.

Resources