By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,955 Members | 752 Online
Bytes IT Community
Submit an Article
Got Smarts?
Share your bits of IT knowledge by writing an article on Bytes.

How I maximize platform and bit independence when programming

SwissProgrammer
P: 98
Platforms that I am interested in my programmings running on:
Windows,
Unix,
Macintosh

Bit versions:
32 bit and 64 bit.

Background:
I have been programming in various languages since the days of card-punch. But, for stand-alone executables, only within the past few years I have (mostly) stopped programming in all of those languages and I am now using (attempting to use) only C++11.

Language choice logic:
I chose C++11 because it is the most currently useful for consumer software applications, game engine applications and development, and industrial applications. I am trying to stay away from Independent Development Environments (IDEs) because, in my experience, they do corrupt C++11.

For that I have chosen a free and open source compiler:
CODE::BLOCKS 17.12 (exactly that version) without wxWidgets.

I studied various other compilers and this was my choice for the previous constraints.

Some background for this choice:
I am programming in C++11 with backward compatibility considerations and for cross platform considerations. I am using CODE::BLOCKS 17.12 so that later I can use the same code on Windows, or Unix, or Macintosh. I am using CODE::BLOCKS 17.12 so that later I can compile the same code in either 32 bit or separately and independently compile it in 64 bit.

For Microsoft Windows users:
CODE::BLOCKS 17.12 on Microsoft Windows XP Professional/Service Pack 2 (not sp3).

In general, compiling with on later versions of Microsoft operating systems have been rejected for the previous backward compatibility constraints and cross platform constraints, etc. That even applies to virtual operating system conditions.

Thus, XP Pro ((32 bit with sp2) or (64 bit with sp1)) has been chosen as the most universally useful platform for programming within these constraints.

I set the compiler options to the following:


GNU GCC Compiler

C Compiler:
mingw32-gcc.exe
C++ compiler
mingw32-g++.exe

with these Compiler Flags:

General
Have G++ follow the C++11 ISO C++ language standard [-std=c++11]
Static linking [-static]
Target x86 (32bit) [-m32]
Warnings
Enable all common compiler warnings (overrides many other settings) [-Wall]
Enable Effective-C++ warnings (thanks Scott Meyers) [-Weffc++]
Warn about unitialized variables which are initialized with themselves [-Winit-self]
Warn if '0' is used as a null pointer constant [-Wzero-as-null-pointer-constant]
Warn if a class has virtual functions but no virtual destructor [-Wnon-virtual-dtor]
Warn if a function can not be inlined and it was declared as inline [-Winline]
Warn if a global function is defined without a previous declaration [-Wmissing-declarations]
Warn if a user supplied include directory does not exist [-Wmissing-include-dirs]
Warn if an undefined identifier is evaluated in an '#if' directive [-Wundef]
Warn if anything is declared more than once in the same scope [-Wredundant-decls]
Warn if floating point values are used in equality comparisons [-Wfloat-equal]
Warn if main() is not conformant [-Wmain]
Warn if the compiler detects that code will never be executed [-Wunreachable-code]
Warn whenever a local variable shadows another local variable, parameter or glogal variable or whenever a built-in function is shadowed [-Wshadow]
Warn whenever a pointer is cast such that the required alignment of the target is increased [-Wcast-align]
Warn whenever a switch statement does not have a default case [-Wswitch-default]
Warn whenever a switch statement has an index of enumerated type and lacks a case for one or more of the named codes of that enumeration [-Wswitch-enum]
Optimization
Don't keep the frame pointer in a register for functions that don't need one [-fomit-frame-pointer]
Optimize general code (for size) [-Os]
Strip all symbols from binary (minimizes size) [-s]

To stay within these constraints (when programming):
I have stopped using wxWidgets.
I have stopped using ".NET".
I have stopped using Visual Studio.

I try to follow rules and guidelines and suggestions that I have found within writings by Stroustrup.

If you chose to follow this process, you may use this article as a reference and link to it. If you are on other sites, and link to here for this, please state that you found this on bytes.com

.
4 Days Ago #1
Share this Article
Share on Google+
2 Comments

Banfa
Expert Mod 5K+
P: 8,978
Hmmm, it's not obvious why you are choosing Windows XP as opposed to a more modern version of Windows.

At my work we use Qt targeting Windows and Linux platforms, although it does support Mac too (and mobile).

For my own tinkering I use Code:Blocks 20.04 and MinGW (whatever is packaged with Code:Blocks)
4 Days Ago #2

SwissProgrammer
P: 98
Banfa,

I tested some Microsoft Windows operating systems beyond XP Pro sp2, and 7 sp1 and found some concerns that I was not willing to accept. The worst was Windows 10.

I can see where some have a need for Windows 10, but I am not a follower thereof. It is powerful. It does a lot of things. It has a lot of capacity. But, currently it is not a system for a lot of people, including myself. I see its need. I do not need it. There are reasons why so many of the next generation of users are rejecting Windows 10. Maybe they will say.

In my experience, "modern" does not always equate to "better" or even "as good". Sometimes, but not always. "Modern" commonly seems to refer to what is on the shelf and/or is being pushed the most by advertisers. Buyer beware. Or as many Business Colleges, in their Master of Business Administration programs, instruct of their graduate level students, "Caveat emptor". It is discussed, sometimes in relation to, "the art of war" by Sun Tzu (~5th century BC)[*]. For a buyer to beware of hard-pushed advertising which denigrates a previously hard-pushed and previously praised product, might be a wise view.


In response to your statement, "it's not obvious why you are choosing Windows XP as opposed to a more modern version of Windows."

I said, without giving much room for XP haters to maneuver (thank you Sun Tzu), "In general, compiling with [or] on later versions of Microsoft operating systems have been rejected for the previous backward compatibility constraints and cross platform constraints, etc. That even applies to virtual operating system conditions."


Qt is nice. I kind of like it. It is cross platform and nice for both CLI and Graphical. But, I had the feeling that it was not quite the direction that I wanted to go.

Again, I like Qt [*].


CODE::BLOCKS 20 [*] is nice and powerful. I considered that might be the best for a while, but I had some software constraints that were better suited with a previous release. I studied previous releases and went back in versions until I found that 17.12 was the latest that I felt fulfilled all of the software requirements.


To recap: Demands on the software that I am working on were a powerful guide to my choice of operating system, C++ version, etc. C++11 is not (currently for me) as fast in production as the Rapid Application Development Visual Studio, and I use work-arounds for some things like getting close to C++20 results, but it it fills the demand better than Visual Studio and better than C++20, and very well.

Thank you for asking.
3 Days Ago #3

Post your comment

Sign in to post your comment or Sign up for a free account.