Where can I find a good guide to writing C Collections? - c

I remember having read a very good guide to writing collections. By that I mean, it described using macros to generate types with type parameters, kind of like C++ templates. I'm not sure if it was written by Rusty Russell, but it was someone I recognized. It was posted on hackernews or proggit... I wanted to write a new C library and has searched google for the past 30 min for this guide to no avail. Anybody remember?

This guide fits your description:
Collections in C by Armin Ronacher.

One example would be queue(3), see queue.h.

Related

C grammar for ANTLR v4

I was wondering if anyone had a working C grammar for ANTLRv4 besides the one on Github?
I can't get the existing one to work at all, it won't even parse the sample files. It may be i'm missing something but I haven't had a problem with any of the other grammars.
I was thinking about modifying the existing one/writing my own, but I don't really have the time - I have limited time to work on this project.
Any help much appreciated.
thanks,
Katy
So you cannot create a working C grammar in less than a few months and it is more complex than it seems like. My opinion is that parsing all C (without preprocessor) takes 6 months to do it well.
For example, the first impression is that C grammar is context-free, but in reality it is context-sensitive.
Take the official grammar from Appendix A of the ISO Standard and start implementing sublanguages from it, inserting nonterminals one by one.

Converting Matlab/C function into version without sourcecode

Im totally new to Matlab. How can I convert a simple Matlab/C function INTO a version that can be run in Matlab WITHOUT showing the source code?? Please help!
As per your clarification the answer you're looking for is the often forgotten matlab pcode.
pcode is a great tool which allows you to distribute matlab code, without giving up the secrets of your source code (m-file). pcode files can ONLY be created on functions. So if you wrote a simple function:
function [y] = myfunction(x)
y=x.^2;
end
Then you could create a pcode file from this with the matlab command :
pcode('myfunction');
you would then have a myfunction.m and a protected myfunction.p.
There is a plethora of online documentation of people trying (unsuccesfully) to translate pcode back to an m-file.
http://www.mathworks.com/matlabcentral/newsreader/view_thread/272505
http://www.mathworks.com/matlabcentral/answers/9848-how-to-decrypt-a-pcode
http://www.mathworks.com/matlabcentral/answers/75012-pcode-obfuscation-cracked-alternatives
As for compiling your C-code, I am not an expert in that area but there are many tools to do so. I personally tend to use gcc. Any further questions about compiling C-code should probably be opened as a new question, or search for some tutorials on getting started with C.

About C documentation

Coming from Java environment, I feel I got spoiled a lot when it comes to documentation. In C, using Eclipse, mouseover putchar() shows:
__CRT_INLINE int __cdecl __MINGW_NOTHROW putchar(int __c)
{
return (--stdout->_cnt >= 0)
? (int) (unsigned char) (*stdout->_ptr++ = (char)__c)
: _flsbuf (__c, stdout);}
While all this is terrific, I was wondering if any IDE includes more information about the specifics of what a given function does, ie, "prints a character to the output device"? Something similar to this as part of an IDE would be awesome.
Is there a way to get this level of detailed as part of Eclipse or any other IDE?
The question, obviously is not about putchar(), but rather is about a general approach to documentation using C programming language.
NetBeans will show you the man page inline: http://netbeans.org/kb/docs/cnd/navigating-editing.html
I don't have a solution for eclipse or an IDE, but my approach usually involves googling the function's manpage. eg, man putchar, which you've already found.
I'll also suggest this, at the risk of downvotes: The IBM C documentation is, in my experience, really good. Often it has real working understandable code examples and everything.
Now, IBM C is different from GNU C, so there are differences or features that do not apply to gcc. That said, Take a look at its page on the putchar() function.
There are plenty of things to complain about in C99, but it is still the authoritative reference and imo the best source for answers to the question, "what does it do?"
MS Visual Studio wraps a little skin around the C99 bones.
And MSDN goes further: docs on MSDN are beginning actually to resemble real papers by real writers that communicate useful info to a wide audience of neophytes and pros alike.
All credit goes to Let_Me_Be.
The following link provides a complete solution to what i was looking for
eclipse.org/linuxtools/projectPages/libhover

Is there any BigDecimal class for C?

I looked all over the internet and I can't seem to find one.
There is something similar in Java, but I need to use C (preferably something I can use locally). Has anyone got any ideas?
Copy of my answer:
If you need to do operations with HUGE decimal values I would suggest you to use http://gmplib.org/ library. I've used it a lot with C and C++.

HAT-trie in ANSI C implementation?

I am looking for ANSI C HAT-trie implementation released under some free license. I have not found one. Can you point me to some standalone implementation or a program that uses
HAT-tries to get at least slight idea how to implement it the roght way, please?
The original paper on HAT-trie can be found here:
http://crpit.com/confpapers/CRPITV62Askitis.pdf
PS: In case faster cache-conscious data structured well-suited for strings evolved since
the time the above paper was written, please point me to the papers or example source codes rather.
Someone is implementing it in C++ over on github
https://github.com/chris-vaszauskas/hat-trie
If you need a plain C implementation, this would be a good base to start from.
Java is also fairly readable for a C programmer
http://www.stochasticgeometry.ie/2008/05/06/implementing-hat-tries-in-java/
Please see the HAT-trie implementation site at code.google.com/p/hat-trie for implementation notes and source code.

Resources