Thread: I made a graphing library in C

  1. #1
    Registered User
    Join Date
    Oct 2018

    I made a graphing library in C


    I made a graphing library in c: CGLib

    It's version 0.1 and i just released it so it may be buggy and have a lot of undefined behavior.

    If anybody tries to use it please tell me what you think. Bring up the negative stuff more than the positive so that i can update it in the next release.


  2. #2
    Registered User
    Join Date
    May 2009
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    My suggestions:
    • Place the header inclusion guard at the very top of the header file. There's no point processing any further if the header has already been included, so this helps the compiler help you.
    • It probably is not wise to define a macro constant named PI. One option is to use a library prefix, e.g., C_GRAPH_PI.
    • Likewise, you really should prefix the struct and function names that form the interface of your library.
    • It looks like your library interface only consists of 5 functions, despite defining quite a few structs. Is that intentional? It seems to me that you require users of your library to create the struct objects by hand, and then pass them to these functions. It is more typical for each struct object to come with initialisation functions and other functions. In fact, you might even choose to make the structs be opaque pointers instead, allowing you to change their layout at will without breaking your library interface compatibility between versions (as long as you don't introduce backward incompatibilities for the interface functions).
    • If there are helper functions in source files that do not form part of your library interface, declare them static. This also means that they won't need a library prefix for their names since the internal linkage means there will be no name collision.
    • Remember to do the simple though tedious things like checking the result of fopen. If you don't, your users will find debugging to be much harder since your functions will just mysteriously fail.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open source graphing / plotting library?
    By sysop in forum C Programming
    Replies: 2
    Last Post: 06-05-2007, 12:20 PM
  2. Graphing with MFC?
    By 99atlantic in forum C++ Programming
    Replies: 3
    Last Post: 04-25-2005, 11:08 AM
  3. My CPrint library... quality printing made easy
    By LuckY in forum Windows Programming
    Replies: 6
    Last Post: 05-17-2003, 02:18 AM
  4. 2d graphing
    By maxthecat in forum Windows Programming
    Replies: 1
    Last Post: 11-09-2002, 12:41 PM

Tags for this Thread