git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: linking libgit.a in C++ projects

From
cte <cestreich@gmail.com>
Date
Jul 31, 2008, 11:10 UTC
Message-ID
<ac9f0f090807310410u461f5584ved74769d8452c539@mail.gmail.com>
In-Reply-To
<20080731105727.GF7008@dpotapov.dyndns.org>
On Thu, Jul 31, 2008 at 3:57 AM, Dmitry Potapov <dpotapov@gmail.com> wrote:
Show 12 quoted lines
> On Thu, Jul 31, 2008 at 02:53:37AM -0700, cte wrote:
>> I'm writing a git gui for OS X using cocoa/Objective-C++, and rather
>> than being lame and parsing the output the various git commands, I'm
>> using libgit.a to provide all of the needed functionality for my app.
>
> Don't do that! libgit.a is an internal library used solely to build
> git binaries. It means that its interface can be cahnged at any time.
> Though, there is an idea of creating the real git library that other
> applications can use, but AFAIK no one is working on it. So parsing
> output is the only correct solution right now. In fact, it is not
> difficult to do, because most plumbing commands are rather flexibly
> in what they output and how.

I'm not worried about the interfaces changing; the gui is tied to a particular version of git, and I will update the code that calls into libgit I pull new changes from the mainline into my local clone. Also, who's to say that the output of the various commands won't change formats with future releases of git? There is no correct solution if you are worried about forward compatibility, unless a well defined API is created (which would be sweet btw, but is probably not a priority).

Show 6 quoted lines
>> However, the git source uses a few reserved C++ keywords; namely
>> 'typename', and 'new'.
>
> Because this source code are meant to be compiled by C and not by C++!
> Even if we will have real git library for other applications to use,
> it still be compiled only by C. Thus, C++ keywords are not issue.
Clearly ;)

Fortunately, g++ can compile C programs and link static libraries that were compiled by C compilers, unless of course, they use C++ keywords. I don't think it is unreasonable to rename the _very few_ C++ keywords in git's source in the interest of allowing C++ projects to leverage libgit.

Previous: Dmitry PotapovNext: Pedro Melo
Message 3 of 26 in “linking libgit.a in C++ projects”
  1. cteJul 31, 2008
  2. Dmitry PotapovJul 31, 2008
  3. cteJul 31, 2008
  4. Pedro MeloJul 31, 2008
  5. Petr BaudisJul 31, 2008
  6. cteJul 31, 2008
  7. Sverre RabbelierJul 31, 2008
  8. cteJul 31, 2008
  9. Sverre RabbelierJul 31, 2008
  10. Shawn O. PearceJul 31, 2008
  11. Sverre RabbelierJul 31, 2008
  12. Steve FrécinauxAug 4, 2008
  13. cteAug 1, 2008
  14. Linus TorvaldsAug 1, 2008
  15. cteAug 1, 2008
  16. Dmitry PotapovJul 31, 2008
  17. Petr BaudisJul 31, 2008
  18. cteJul 31, 2008
  19. Dmitry PotapovJul 31, 2008
  20. Boaz HarroshJul 31, 2008
  21. Dmitry PotapovJul 31, 2008
  22. Alex RiesenJul 31, 2008
  23. Avery PennarunJul 31, 2008
  24. Alex RiesenAug 3, 2008
  25. Boaz HarroshAug 4, 2008
  26. cteJul 31, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.