473,421 Members | 1,638 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,421 developers and data experts.

How I maximize platform and bit independence when programming

SwissProgrammer
220 128KB
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

.
Oct 17 '20 #1
2 3250
Banfa
9,065 Expert Mod 8TB
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)
Oct 17 '20 #2
SwissProgrammer
220 128KB
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.
Oct 18 '20 #3

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

Similar topics

4
by: 0to60 | last post by:
I have a question about socket programming in general. Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I...
2
by: Andreas Klemt | last post by:
Hello, for what is the label good when programming in visual studio like this: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1: ...
1
by: PW | last post by:
Hi, Is it possible to make a control bigger or maximize it also when the user maximizes the form? I have a calendar control on a form and I would like to automatically make it bigger when the...
16
by: Andy | last post by:
Hi, I have read that 'C' is platform-independent and portable. I can'tsee much a difference between the two terms. Could anyone differentiate the two? Also is the statement actually true? Thanks...
8
by: Joel | last post by:
If I'm not wrong, .NET generates MSIL which can be executed by the CLR on any machine because the code is managed, but what if a programmer decides to use a bit of unmanaged code, say a feature of...
4
by: toddw607 | last post by:
Anyone know how I set the property to open up a report or a form in a maximized view inside the database window? Right now all the windows open up minimized with min/max buttons on the form/report. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.