D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] C++

 

>> My recollection is one has different flavours of C++, particularly as
>> regards the GUI (or API).  I do not think for instance that I can
>> compile Microsoft C++ on my linux machine  (The stuff is just not in the
>> libaries?).
>>

As others have pointed out there are many layers to the question.

However even if you stick to core standard C++ and the STL your source
 gets compiled to native code that runs on your platform so you need a
suitable compiler for all target platforms (and that is particularly
unlikely if you use generics//templates).

Further it is perfectly possible to write code that makes assumptions
about the platform and breaks on others. This can be done unwittingly
and most often involves assuming layout of data in memory, big/little
endian and size of types and pointers (pointers add more fun
possibilities for broken portability). As soon as your start working
with OS objects like files or processes it all gets even more complex.
There are various approaches for dealing with this like conditional
compilation (hard to manage), build time, abstraction layers that
localise the platform dependencies, runtime testing.

Personally for this and several other reasons I now use languages that
soak up all these differences for you and for my money Python does a
fantastic job (but you still need to take care in a few areas like OS
paths). Oh python hooks well to C++ modules so you can mix.

Steve Lee

2008/11/20 Anthony Williams <anthony@xxxxxxxxxxxxxxxxxxxxxxxxxxx>:
> At Thu 20 Nov 2008 10:05:31 UTC, peter <peter@xxxxxxxxxxxxxxxxxxxx> wrote:
>
>> Before I stick my neck out and offer advice I am asking here to be sure
>> of my facts before giving any. (If he wants to write in C++ that's his
>> problem, however it would be nice if all platforms could run his game
>> (which brings us back to Java (VBG).  In any case another member is
>> talking of porting stuff to Linux.
>>
>> I know there is an ANSI C but is there a C++.  Or a way that makes the
>> code work with the GNU C++ compiler.
>
> Yes, there is an ANSI/ISO Standard for C++; there has been since 1998,
> and there's a new one due out any year now. So, plain C++ code that
> uses nothing but the standard libraries is portable across loads of
> platforms, including Windows and Linux.
>
> However, the standard libraries do not include things like GUI and
> network libraries, so there are numerous versions of these, many of
> which are platform specific. On Windows, for example, you can write
> code directly against the Windows API, or use a class library such as
> MFC which is provided with the Microsoft compiler. OTOH, on Linux you
> can code against the POSIX APIs, and use the X API for GUIs.
>
> If you want to write portable GUIs, use a toolkit such as Qt or
> WxWidgets or SDL which is designed to be portable. The same goes for
> networking and just about everything else.
>
> Anthony
> --
> Anthony Williams
> Author of C++ Concurrency in Action | http://www.manning.com/williams
>
> Custom Software Development | http://www.justsoftwaresolutions.co.uk
> Just Software Solutions Ltd, Registered in England, Company Number 5478976.
> Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK
>
>
>
> --
> The Mailing List for the Devon & Cornwall LUG
> http://mailman.dclug.org.uk/listinfo/list
> FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html
>



-- 
Steve Lee
Open Source Assistive Technology Software and Accessibility
fullmeasure.co.uk

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html