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.
101
questions
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 ...
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 ...
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 ...
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 ...
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 (...
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 ...
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. ...
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 ...
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 ...
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 ...
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-...
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 ...
11
votes
1
answer
1k
views
Portable safe unsigned integer arithmetic
tl;dr The purpose of the code is to allow writing
...
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 ...
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:
...
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.
...
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:
<...
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 ...
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 ...
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 ...
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 ...
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.
...
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 ...
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 ...
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 ...
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)....
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 ...
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 ...
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:
...
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.
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
6
votes
1
answer
269
views
Correct and portable serialization
So I've made custom binary streams which work like this:
...
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 ...
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 ...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
5
votes
1
answer
658
views
Modular exponentiation without range restriction
A typical modular exponentiation may be coded using the following algorithm.
...
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' ...
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 ...