Questions tagged [portability]

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

Filter by
Sorted by
Tagged with
28 votes
2 answers
42k views

Windows keylogger in C

I have had this keylogger code for a while now (a few years*), and I figured I would put it up for review. Here is what I would like reviewed (in order): Portability - right now, this program can ...
syb0rg's user avatar
  • 21.8k
23 votes
1 answer
1k views

Portable CMake script

I'm trying to write a portable CMake script for a simple Qt application. The target platforms are Win and Mac OSX. But as you can see, it's quite a monster already. Are there any CMake profs? Can you ...
Roman Kruglov's user avatar
18 votes
2 answers
533 views

The birth of my intelligent assistant: Khronos

I've done a lot of reworking to this main file recently, in regards to using a new speech recognition engine and integrating the last reviews suggestions. My question before is going to be phrased ...
syb0rg's user avatar
  • 21.8k
17 votes
1 answer
2k views

Brainfuck-to-C compiler written in C++

This compiler, implemented in C++, takes brainfuck code and produces a valid (but still obfuscated) C program, which in turn can be compiled to a native binary. Expected usage is as follows: Build ...
200_success's user avatar
16 votes
5 answers
19k views

Unix shell function for adding directories to PATH

Adding a directory to the PATH in Unix/Linux is a very common task. However, what if the directory is already in the path? My goal is to write a shell function (...
Sildoreth's user avatar
  • 273
15 votes
2 answers
26k views

Restricting user to one open tab in browser

I had a requirement to restrict my web site's users to just one open tab in the browser. I am aware that this is not the best thing to do in terms of general user experience guidelines, but it's an ...
Ali Kazmi's user avatar
  • 271
15 votes
1 answer
263 views

Khronos: Primary CMake file

So recently I made a large project of mine open source: Khronos. I will be dissecting parts of it so that I can have it reviewed more easily here and so that the project as a whole will be improved. ...
syb0rg's user avatar
  • 21.8k
14 votes
2 answers
3k views

malloc() and free() for Linux with system calls

I have written an implementation of malloc() and free() for Linux using the sbrk() system ...
jess's user avatar
  • 1,378
13 votes
5 answers
3k views

Portable old-school filesystem tool

I recently made a tool called mkfh to create a FHS compliant filesystem structure. I aimed to make it as portable as possible, so I wrote it in C89 and also tried ...
Labricecat's user avatar
12 votes
3 answers
26k views

Endianness conversion in C

I have written a simple C header for converting the endianness of short integers and long integers. It uses the GCC macro ...
Jack Wilsdon's user avatar
  • 1,651
12 votes
1 answer
220 views

Not so Excellent Knight's Tour

Note: This is part of a set of demo applications I'm writing for colleagues to show we're not limited to VBA when dealing with Excel. Considering our IT challenges (no admin on-site & no local-...
Mast's user avatar
  • 13.4k
11 votes
2 answers
1k views

jQuery plugin that makes a slider out of an <ul> list

This is one of my very first jQuery plugins. In short: it makes a slider out of an <ul> list filled with <li> items ...
D4V1D's user avatar
  • 111
11 votes
1 answer
1k views

Portable safe unsigned integer arithmetic

tl;dr The purpose of the code is to allow writing ...
5gon12eder's user avatar
  • 4,280
10 votes
4 answers
4k views

Portable periodic/one-shot timer thread - follow-up

This is a much improved version (I hope) of code in this previous code review of mine. I have: renamed several things. Are the names good? made it lazily start the worker thread only after the first ...
doug65536's user avatar
  • 533
10 votes
1 answer
2k views

Recording audio in C 2.0

I posted my audio recording program to Code Review before, and received a stern review along with the other reviews that caused me to rewrite the entire code base. Here is what I would like reviewed: ...
syb0rg's user avatar
  • 21.8k
9 votes
3 answers
2k views

Executing a shell command OS-independently

The goal of the code is to convert a Graphviz DOT file to an SVG file, and it achieves this by creating a child process and executing the "dot" command. ...
Harith's user avatar
  • 5,667
9 votes
2 answers
1k views

Serial port library across different compilers

I'm writing a C++ library with MinGW (4.8.0, DW2, POSIX) compiler. But this library must be used by another compiler. I've read this post, so I've re-written the C++ library interface in this way: <...
Elvis Dukaj's user avatar
8 votes
1 answer
922 views

Guessing the JDK home directory

My project is using a specific version of JDK which is jdk-6 and the default JDK_HOME path will vary from distribution to distribution, so I wrote a script to guess it. Is there any way to do this ...
sandun dhammika's user avatar
8 votes
2 answers
1k views

Making multiple copies of a pattern

Here's a function for making multiple copies of a block of memory in another block of memory. It handles the case when the size of the target is smaller than or not a perfect multiple of the source ...
user avatar
8 votes
2 answers
300 views

What should a C++ error reporting exception class have to be portable across language versions? (ver 1)

Link to revised (ver 2) question This question contains the first version of the code for the task explained below. The revised version is at C++ exception class for error reporting, compatible with ...
Scott McPeak's user avatar
8 votes
2 answers
5k views

Speed optimization for block XOR

In code I'm currently maintaining, there is a need to do very many repeated XOR operations of blocks of memory. The block size in my case is always 16 bytes. Because the code is executed very ...
Edward's user avatar
  • 66.4k
8 votes
1 answer
702 views

VLC media player watchdog daemon

I'm looking for bugs, ways to make it more portable or standardized, improvements of any kind. Seems to do what it is supposed to on my Ubuntu 12.04 PC. ...
JB0x2D1's user avatar
  • 271
8 votes
1 answer
137 views

Portability in using up-and-coming library features

Currently, some library features are not in std that comes with the compiler, but may be in std::experimental or may not be ...
JDługosz's user avatar
  • 11.3k
8 votes
1 answer
518 views

Looping until browser document is ready

I made a do...while loop in order to wait for the web browser to load completely in order to enter username and password. I don't know whether this impacts the ...
thomasxd24's user avatar
7 votes
2 answers
622 views

Consolidating GNU C's and C23's attributes

C23 has introduced attribute specifier sequences. Consequently, the header below attempts to conditionally define macros for these sequences (for my own use cases). In cases where a compiler does not ...
Harith's user avatar
  • 5,667
7 votes
1 answer
675 views

UTF-8 character reader function

You may see full code here (note that the link points to the specific commit). Language is "clean C" (that is, a subset of C89, C99 and C++98 — it is intended to compile under all of these standards)....
Alexander Gladysh's user avatar
7 votes
1 answer
336 views

Wrapper to enhance a program to translate from LTL formulae to Büchi automata

The following is a script that is supposed to act as a wrapper for ltl2ba, a program which transforms LTL formulas into Buchi Automatons encoded in the Promela language. The wrapper adds a limited set ...
Patrick Trentin's user avatar
7 votes
2 answers
2k views

Portable byte order conversion

I'm trying to improve the portability of a file format converter, specifically to POSIX platforms other than Linux. I'd appreciate a review of the following functions used for converting between ...
zanyelf's user avatar
  • 73
7 votes
2 answers
92 views

Pseudoportable C script pattern - follow-up

See the initial/previous iteration. I have rewritten the script following the answer of @200_success. Now it looks like this: ...
coderodde's user avatar
  • 28.2k
7 votes
2 answers
82 views

Printing the days of the week for every day this year

@chux pointed out that my attempted solution contained several problems. Since I screwed that up so badly, I figure that I should put my revised solution up for review. ...
200_success's user avatar
7 votes
0 answers
752 views

Unity3D shader for rendering 2D sprites with a pseudo-glitch effect

I'm making a puzzle game in Unity with sprite-based graphics. When the game is paused, I want to hide most game elements, because I don't want the player to be able to pause and leisurely think about ...
JesseTG's user avatar
  • 459
6 votes
2 answers
33k views

Timestamp function with millisecond precision

I want to be able to print timestamps with milliseconds precision and time_t doesn't provide this. I also want the code to be portable, so operating specific ...
arcomber's user avatar
  • 2,449
6 votes
2 answers
1k views

Cross-platform file hash sum generator in Python

I'm back for more community punishment review of my own scripts and code! This time, I'm looking for general code review of my approach to a Python way of getting one or more hash sums for a provided ...
Thomas Ward's user avatar
  • 2,518
6 votes
1 answer
88 views

Pseudoportable C script pattern

(See the next iteration.) From time to time, while working with a command line in *nix family of operating systems, we have to write those scripts doing a rather specific task. Usually we use ...
coderodde's user avatar
  • 28.2k
6 votes
3 answers
545 views

Cross-platform performance and statistical information script

My usual disclaimer, I'm new to Python and scripting and I'm still studying the PEP8 guide, so please forgive any huge failures with respect to syntax, formatting and style. I'm open to any ...
Chris Gleason's user avatar
6 votes
1 answer
2k views

Program that replicates itself

While misreading the beginning of Stage I of this classic paper by Ken Thompson, I decided to create program that replicates itself. Let's say this program is called Replicator.exe. Upon running it ...
jliv902's user avatar
  • 1,952
6 votes
1 answer
121 views

Pathname matching and listing program

This Python 3 program outputs a list of all pathnames in the filesystem that match a list of rules taken from a file. You can add and remove sets of pathnames. The original purpose was to generate ...
Tom Zych's user avatar
  • 421
6 votes
1 answer
1k views

ANSI colors cross platform

I am trying to write for both NT and POSIX (my two usual platforms) and have come up with the code below. The clrs code I refer to is apparently from blender build ...
Dee's user avatar
  • 61
6 votes
1 answer
269 views

Correct and portable serialization

So I've made custom binary streams which work like this: ...
user avatar
6 votes
2 answers
136 views

Inferring Memory Alignment

The following code is intended to infer the alignment of double. My questions include: Is there a better to do this? Either by refining the code or using an ...
user avatar
5 votes
2 answers
2k views

Portable Python CSV class

I have been working on a project where I needed to analyze multiple, large datasets contained inside many CSV files at the same time. I am not a programmer but an engineer, so I did a lot of searching ...
devfarce's user avatar
5 votes
2 answers
354 views

VLC media player watchdog daemon v6

This question is a follow-up to a previous version of this program, which I wrote because I found it annoying that VLC Media Player (which I love) prevents the screensaver from starting after playback ...
JB0x2D1's user avatar
  • 271
5 votes
2 answers
821 views

Header file that includes all standard C library headers

The Standard C Library consists of various headers files. Often only a few select ones are needed for given code. Other times it is simply convenient coding to include them all in a .c file, even if ...
chux - Reinstate Monica's user avatar
5 votes
3 answers
14k views

Checking endianness at compile-time

I've tried to make a portable way of ensuring endian-specific code gets generated at compile time using C++11, however I only have a computer with Windows on it to test at the moment. Because of this, ...
icdae's user avatar
  • 151
5 votes
2 answers
240 views

JavaScript parallax cross-platform efficiency

I wanted to get some feedback on this JS I am working on. It works wonderfully on my desktop, but on my and my friends' laptops (especially Safari) it is very slow. I need some pointers on improving ...
Francisco Aguilera's user avatar
5 votes
1 answer
556 views

Vertical-align in Nested Column

Requirements: There are two columns. The left column is fixed width. The height of two Column should be the same. Left column contain a title (can be multi-line) and an Image (limit max width to ...
Cass03's user avatar
  • 51
5 votes
1 answer
215 views

Portability and "dark corner" gotchas in this "watchdog" program

The following program is intended to "watchdog" a child process, and all subprocesses the child spawns. The intended behavior is: A child process (as specified on the command line) is run in a ...
zwol's user avatar
  • 411
5 votes
1 answer
658 views

Modular exponentiation without range restriction

A typical modular exponentiation may be coded using the following algorithm. ...
chux - Reinstate Monica's user avatar
5 votes
1 answer
316 views

Two cross-platform implementations of getline in C

I created my cross-platform implementations of getline function in C. It takes different arguments and have different return values than 'original' ...
DeBos's user avatar
  • 525
4 votes
2 answers
6k views

Colored <hr> in emails

Sometimes, I need to change the color of <hr> elements in an email. The only achieveable way is by using CSS. But not every email client supports CSS. Most ...
Ismael Miguel's user avatar