Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Can Allegro library be used with C only?

This thread is locked; no one can reply to it. rss feed Print
Can Allegro library be used with C only?
sabino
Member #16,000
June 2015

Or, am I forced to use C++? Thank you :)

Elias
Member #358
May 2000

I'm using it with C only - I'd never touch C++.

--
"Either help out or stop whining" - Evert

bamccaig
Member #7,536
July 2006
avatar

Allegro can be used with any language for which C can be used. This list is big. C and C++ can interface with it directly. Other languages you will typically need to add bindings of some kind. Many unofficial bindings already exist, such as for Python, though your mileage with them may vary.

Append:

Oh, yes, Allegro is a pure C library (I think they have added some C++ internally now, but the public API is still purely C). You can use it with pure C.

sabino
Member #16,000
June 2015

Thank you all. :)

SiegeLord
Member #7,827
October 2006
avatar

On Windows, since Allegro uses C++ to interface with Direct3D, you need to link the C++ runtime even if youre project is pure C.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Bruce Pascoe
Member #15,931
April 2015
avatar

Can't you use D3D in C? I thought you could, I know years ago I made a DX7 game with lcc-win32 and that worked well enough.

It's admittedly a lot more tedious because you have to reference the vtable on the COM objects directly (i.e.: device->vtable->Flip() or somesuch), but it can be done.

Trezker
Member #1,739
December 2001
avatar

I use Allegro in D. Works really well.

Elias
Member #358
May 2000

Can't you use D3D in C?

Yes, but the dependency on libstdc++ doesn't warrant a rewrite (nor the possibly harder to read code). If you are desperate enough to want to create a Windows .exe you can as well have some overhead of having the C++ standard library compiled in. OSX is even worse btw., Allegro internally uses objective C there. The only sane OS is Linux really.

--
"Either help out or stop whining" - Evert

Bruce Pascoe
Member #15,931
April 2015
avatar

@Elias
Yeah, I wasn't suggesting rewriting all of Allegro's D3D routines in C, that would be stupid and a complete waste of time. Mostly I was just genuinely curious if DX-in-C was still a thing, I haven't touched it since my DX7 days. Either way, Allegro using C++ to interface with DX was clearly the sane choice. Dealing with COM is enough of a headache as it is. :)

To be clear, the dependency on libstdc++ doesn't bother me in the least. I use MSVC for the most part, which (AFAIAA) links the same standard library regardless whether it's a C or C++ app. So a complete rewrite wouldn't even do me any good. :P

As for OS sanity, it probably helps that Linux itself is entirely written in C. ;)

Go to: