Questions tagged [portability]

Portable code can be run with little to no modification in multiple environments. Portable applications can be run from e.g. a USB drive without modifying a computer's environment.

Portable code can be run with little to no modification in multiple environments. This is typically achieved by either abstraction or specialization.

Abstraction is achieved by using a programming language or library which sits between your code and the platforms it runs on, attempting to obscure the differences between them. Any programming language which does not compile to native code attempts to provide some level of such abstraction.

Specialization requires writing code which is aware of the nuances of various environments and adapts to them. This technique is used by many *nix projects, often assisted by capability-detection tools.

Achieving the best possible portability may well involve using both methods in concert.

Portable applications can be run without modifying a computer's environment, such as by storing all configuration data inside the application folder rather than employing system-level configuration.

Such applications are designed to run without altering files on the computer's hard drive, including system config files, type associations, and the like. The goal of such portability is to ensure the application can run when side effects are undesirable, such as when installed on a removable drive or when a user does not have sufficient permission to install software.

1398 questions
44
votes
7 answers

How to design a C / C++ library to be usable in many client languages?

I'm planning to code a library that should be usable by a large number of people in on a wide spectrum of platforms. What do I have to consider to design it right? To make this questions more specific, there are four "subquestions" at the…
Lena Schimmel
  • 6,934
  • 5
  • 41
  • 56
42
votes
2 answers

Autotools vs CMake for both Windows and Linux compilation

I have been looking for pros & cons of Autotools and CMake. But I would like to know opinions from people having used one (or both) of these tools for projects. I used Autotools very basically a year ago and I know that one of the good points is…
Julio Guerra
  • 4,877
  • 7
  • 44
  • 66
41
votes
3 answers

C++: Is there a standard definition for end-of-line in a multi-line string constant?

If I have a multi-line string C++11 string constant such as R"""line 1 line 2 line3""" Is it defined what character(s) the line terminator/separator consist of?
Mark Harrison
  • 267,774
  • 112
  • 308
  • 434
41
votes
7 answers

What's the difference between "int" and "int_fast16_t"?

As I understand it, the C specification says that type int is supposed to be the most efficient type on target platform that contains at least 16 bits. Isn't that exactly what the C99 definition of int_fast16_t is too? Maybe they put it in there…
something_clever
  • 756
  • 5
  • 16
41
votes
7 answers

Can placement new for arrays be used in a portable way?

Is it possible to actually make use of placement new in portable code when using it for arrays? It appears that the pointer you get back from new[] is not always the same as the address you pass in (5.3.4, note 12 in the standard seems to confirm…
James Sutherland
  • 3,617
  • 2
  • 24
  • 24
40
votes
3 answers

GLIBCXX versions

If I compile a C++ program on my machine, and run it on another one (with older software) I get: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found. In fact on my system glibc is newer (I got gcc-libs 4.5.1: libstdc++.so.6.0.14) and strings…
peoro
  • 24,051
  • 18
  • 90
  • 141
40
votes
8 answers

A step-up from TiddlyWiki that is still 100% portable?

TiddlyWiki is a great idea, brilliantly implemented. I'm using it as a portable personal "knowledge manager," and these are the prize virtues: It travels on my USB flash memory stick and runs on any computer, regardless of operating system No…
Smandoli
  • 6,722
  • 3
  • 43
  • 80
39
votes
8 answers

msys path conversion (or cygpath for msys?)

I need to pass /DEF:c:\filepath\myLib.def" command line option from a bash script to MS compiler/linker. The path is generated as part of build process by a bash script. Basically, the argument that my script passes…
Pavel P
  • 13,962
  • 11
  • 68
  • 109
37
votes
20 answers

How do you deal with Internet Explorer?

I am aware that there are probably other questions regarding this topic. I guess that every web developer goes through this with IE. My problem: I am developing a web-based application fully based on Javascript. I am a Mac user. I was really happy…
fmsf
  • 33,514
  • 48
  • 140
  • 190
37
votes
2 answers

What is the smallest possible Windows (PE) executable?

As a precursor to writing a compiler I'm trying to understand the Windows (32-bit) Portable Executable format. In particular I'd like to see an example of a bare-bones executable which does nothing except load correctly, run and exit. I've tried…
Matthew Murdoch
  • 28,946
  • 26
  • 89
  • 125
36
votes
3 answers

What is the most portable/cross-platform way to represent a newline in go/golang?

Currently, to represent a newline in go programs, I use \n. For example: package main import "fmt" func main() { fmt.Printf("%d is %s \n", 'U', string(85)) } ... will yield 85 is U followed by a newline. However, this doesn't seem all that…
carbocation
  • 7,064
  • 7
  • 21
  • 24
34
votes
12 answers

How should I handle "cast from ‘void*’ to ‘int’ loses precision" when compiling 32-bit code on 64-bit machine?

I have a package that compiles and works fine on a 32-bit machine. I am now trying to get it to compile on a 64-bit machine and find the following error- error: cast from ‘void*’ to ‘int’ loses precision Is there a compiler flag to suppress these…
badkya
  • 677
  • 2
  • 8
  • 13
33
votes
6 answers

Preventing MSYS 'bash' from killing processes that trap ^C

I have a console-mode Windows application (ported from Unix) that was originally designed to do a clean exit when it received ^C (Unix SIGINT). A clean exit in this case involves waiting, potentially quite a long time, for remote network…
zwol
  • 121,956
  • 33
  • 219
  • 328
33
votes
6 answers

Building a 32-bit float out of its 4 composite bytes

I'm trying to build a 32-bit float out of its 4 composite bytes. Is there a better (or more portable) way to do this than with the following method? #include typedef unsigned char uchar; float bytesToFloat(uchar b0, uchar b1, uchar b2,…
Madgeek
  • 333
  • 1
  • 3
  • 6
33
votes
4 answers

c++ Initializing a struct with an array as a member

Edited again because it originally wasn't clear that I'm trying to initialize the arrays at compile time, not at run time... I've got the following reduced testcase: typedef struct TestStruct { int length; int values[]; }; TestStruct t =…
Drew Shafer
  • 4,520
  • 4
  • 28
  • 40
1 2
3
93 94