Questions tagged [platform-independent]

Software or peripherals intended to permit uniform functionality on multiple platforms, such as multiple operating systems or multiple devices.

Overview

  • This tag should be marked as synonymous with [cross-platform].

See also

123 questions
247
votes
5 answers

Node.js - Find home directory in platform agnostic way

Process.platform returns "win32" for Windows. On Windows a user's home directory might be C:\Users[USERNAME] or C:\Documents and Settings[USERNAME] depending on which version of Windows is being used. On Unix this isn't an issue.
142
votes
2 answers

File.separator vs FileSystem.getSeparator() vs System.getProperty("file.separator")?

There seems to be three identical ways to get the platform-dependent "file separator" platform-independently: java.io.File.separator java.nio.file.FileSystems.getDefault().getSeparator(); System.getProperty("file.separator") How do we decide when…
Pacerier
  • 76,400
  • 86
  • 326
  • 602
110
votes
10 answers

Play a Sound with Python

What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound.
Claudiu
  • 206,738
  • 150
  • 445
  • 651
92
votes
3 answers

Platform independent size_t Format specifiers in c?

I want to print out a variable of type size_t in C but it appears that size_t is aliased to different variable types on different architectures. For example, on one machine (64-bit) the following code does not throw any warnings: size_t size =…
Ethan Heilman
  • 14,869
  • 10
  • 58
  • 88
56
votes
9 answers

Where is Boost.Process?

I need to execute a program and retrieve its stdout output in c++. I'd like my code to be cross-platform too. Having recently discovered the wonderful world of the Boost c++ libraries for all your cross platform needs, I figured I'd just go to…
TC.
  • 3,825
  • 3
  • 28
  • 32
26
votes
2 answers

What is os.linesep for?

Python's os module contains a value for a platform specific line separating string, but the docs explicitly say not to use it when writing to a file: Do not use os.linesep as a line terminator when writing files opened in text mode (the default);…
SuperBiasedMan
  • 8,997
  • 9
  • 43
  • 66
24
votes
9 answers

Remove filename from a URL/Path in java

How do I remove the file name from a URL or String? String os = System.getProperty("os.name").toLowerCase(); String nativeDir = Game.class.getProtectionDomain().getCodeSource().getLocation().getFile().toString(); //Remove the…
Yemto
  • 443
  • 1
  • 4
  • 17
22
votes
3 answers

How to check if an arbitrary PID is running using Node.js?

Is there some way to check if an arbitrary PID is running or alive on the system, using Node.js? Assume that the Node.js script has the appropriate permissions to read /proc or the Windows equivalent. This could be done either synchronously: if…
Zac B
  • 3,247
  • 3
  • 28
  • 46
20
votes
1 answer

How to write platform-independent code in Haskell (ghc)

There are a few platform-specific libraries in Hackage that I'd like to use (e.g. inotify, kqueue). However, documentation on how to switch between platforms using conditional compilation seems a little bit sparse. I'm having some trouble finding…
Rehno Lindeque
  • 3,796
  • 2
  • 18
  • 29
19
votes
2 answers

Why can an executable run on both Intel and AMD processors?

How is it that an executable can work on both AMD and Intel systems. Aren't AMD's and Intel's instruction sets different? How does the executable work on both? How exactly do they compile the files to work like that. And what exactly is the role of…
16
votes
10 answers

C++ Converting a time string to seconds from the epoch

I have a string with the following format: 2010-11-04T23:23:01Z The Z indicates that the time is UTC. I would rather store this as a epoch time to make comparison easy. What is the recomended method for doing this? Currently (after a quck…
Martin York
  • 234,851
  • 74
  • 306
  • 532
15
votes
3 answers

Portable printing of exponent of a double to C++ iostreams

I want to print a double value to std::cout portably (GCC, clang, MSVC++) such that the output is the same on all platforms. I have a problem with the formatting of the exponent. The following program #include int main() { std::cout…
Manuel
  • 6,173
  • 6
  • 32
  • 52
13
votes
2 answers

What is wrong with printf("%llx")?

I have this piece of code that is challenging all my knowledge of C. Here I have : int main(void){ unsigned long long int massage ; scanf("%llX", &massage); //input: 0x1234567890abcdef printf("%llX", massage); return 0; } On my…
Untitled
  • 761
  • 1
  • 6
  • 24
11
votes
5 answers

Is -1u valid c++?

Is for example size_t x = -1u; if (x == -1u) ... valid? If this is valid it would prevent a warning. of course on a 32 bit system x should be 0xffffffff and on a 64 bit system it should be 0xffffffffffffffff. -Jochen
Jochen
  • 716
  • 5
  • 21
9
votes
2 answers

How to get system environment variables using boost library?

I work on windows and MacOS, I would like to get environment variables. How to get system environment variables using boost library? Are there equivalent to System.Environment.GetEnvironmentVariable() from .Net ?
Arman
  • 4,387
  • 10
  • 38
  • 63
1
2 3
8 9