-2

I would like to write a project in C on linux. The simplicity and universality of binding to C from other computer programming languages makes it a preferential choice over other computer languagues, such as C++, Obj-C, D, C#, etc.

Unfortunately, some of C's limitations drive me batty. (IDEs don't solve them all. They plaster over some. Besides, I use emacs, gcc, and cgdb.)

  • I would rather have multi-pass forward scanning of function definitions, so I don't need prototypes; and I would rather not have to have .h files. I can then put everything from one "module" into one and just one .c file. Maybe this needs a "public" keyword to designate any function symbols I want to export.

  • I would love optional arguments on functions: function x(y =0).

These are collections of itches. All fairly pedestrian. Nothing as complex as a full language, much less a real new feature such as garbage collection or inheritance. More like C 11.1. It would just require a more sophisticated preprocessor. Writing such a preprocessor for C [in perl] would not be too hard, but writing all the tools that go with it would require in-depth knowledge of the common support tools (emacs, gdb, etc.) which I do not have.

(more pedestrian request: a pragma that states to zero all structs and arrays upon creation. Pass through of '...' varargs. true doc support---doxygen has idiosyncracies. multiline support.)

are there any such extendable C solutions in gcc? the gap between C and C++ is way too far, but the valley in between seems to have few choices that retain the advantages of C.

ivo Welch
  • 2,427
  • 2
  • 23
  • 31
  • 1
    These are at least two questions. You _can_ do some macro-hackery to get default arguments and there are tools for generating header files from .c files; I remember both being answered here on SO somewhere before. And the header “problem” is something you face in C++ as well, btw. – mafso Jul 18 '14 at 22:20
  • And what do you mean by “Pass through of '...' varargs” and “multiline support”? – mafso Jul 18 '14 at 22:26
  • "pass through of ..." is not really important, but R has a much nicer way to do this: _int notify(int extra, ...) { printf("%d", extra); printf(...); }_ whatever is in '...' is then just passed on the same way. more pleasant than the vararg contortions in many cases. – ivo Welch Jul 19 '14 at 08:03
  • thanks, mafso. 3rd party tools for header generation are available. http://www.lazycplusplus.com/ , http://stackoverflow.com/questions/1404614/automatically-generate-c-file-from-header , http://www.hwaci.com/sw/mkhdr/ . alas, some may break doxygen, gdb, emacs . need to investigate more. I was hoping there would be something more systematic with many niceties and wider support. – ivo Welch Jul 19 '14 at 08:12
  • "[...] the valley in between seems to have few choices that retain the advantages of C." lol nope – Griwes Aug 22 '14 at 15:55
  • 1
    Have you looked into [Vala](http://en.wikipedia.org/wiki/Vala_%28programming_language%29)? it emits C. – knarf Aug 22 '14 at 15:55

1 Answers1

0

this does not solve all of the C woes, but it improves it:

http://www.hwaci.com/sw/mkhdr/

provides makeheaders, which generates .h files from each .c file that take care of prototypes, including for forward references and keeping .c and .h files in sync. big improvement for me.

ivo Welch
  • 2,427
  • 2
  • 23
  • 31