Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
2answers
42 views

Platform-agnostic windowing library

I am making a C library that abstracts window creation with support for the new Vulkan API under a unified API; I have a github repository that you can check out. main.c ...
11
votes
2answers
999 views

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

I have written an implementation of malloc() and free() for Linux using the sbrk() system ...
-1
votes
1answer
153 views

Creating a Compatibility Shim for ExampleClass to be targeted both to .net framework and .net core 2.0

Intro: Before showing the actual code for review, let me show you an ExampleClass to create a shim for. ...
3
votes
3answers
113 views

Safely & portably read a value into a predefined integral type of varying size like mode_t

I need to read a value from a text file and put it into a predefined type, in this particular case mode_t. This typedef can have a variety of types underlying it, ...
1
vote
1answer
81 views

Galton Board Simulation

This program is written for Windows 7 under MinGW using gcc. I'm seeking recommendations for improving the program's portability. ...
1
vote
2answers
72 views

Portable (Linux, Cygwin,…) Makefile for my own Shell OpenSSL file en-/decryption scripts

Let it be clear that in this question I ask for further guidance with my current version of Makefile used for my own Shell OpenSSL file en-/decryption scripts, not ...
8
votes
1answer
87 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 ...
3
votes
1answer
43 views

Function declarations using macros to support multiple platforms

I wrote a C++ plugin that retrieves screen pixel. It works on Windows and Android. I noticed that dllexport is only required on Windows but not on Android and ...
3
votes
2answers
3k views

HTTP request parser in C

I'm implementing a simple HTTP server in C, and this is the first part of it. Basically, it takes a string containing a "raw" HTTP request, and parse it into a ...
4
votes
1answer
139 views

Modular exponentiation without range restriction

A typical modular exponentiation may be coded using the following algorithm. ...
4
votes
3answers
259 views

Portable multithreaded matrix multiplication in C

I essentially took this progam, and made it compile and run on Windows too. Also, I incorporated some nice points made by Toby Speight. matrix.h ...
7
votes
1answer
129 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 ...
1
vote
1answer
96 views

Conditionally loading a terminal or cli with node.js

I've been working a side project recently, when ever I have time, to make a small script that determines what Command Line Interface to load using node.js and its ...
1
vote
1answer
716 views

Forced and easy hton/ntoh conversion

Context: When sending message across the network, the sender has to convert the message from host byte order to network byte order and the receiver has to do the the reverse - network order to host ...
12
votes
3answers
5k 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 ...
8
votes
1answer
888 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 ...
3
votes
1answer
401 views

C++ small 2D matrix class

I make a 2D matrix class (where matrix elements are of type float) which so far can: Create a matrix of zeros of any size by typing ...
5
votes
2answers
341 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 ...
2
votes
0answers
189 views

Library for manipulation of binary protocol headers

I'm starting with implementing a TCP/IP stack for embedded systems which will be done in C++ and I've found I need a good way to work with protocol headers involved (e.g. ARP, IP, TCP). Major ...
5
votes
1answer
172 views

Correct and portable serialization

So I've made custom binary streams which work like this: ...
4
votes
1answer
58 views

Secure file system utility functions

For Khronos, I've had to develop these utility functions to help me deal with storing the .wav files. However, they could also be used in a variety of applications....
18
votes
2answers
467 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 ...
11
votes
1answer
803 views

Portable safe unsigned integer arithmetic

tl;dr The purpose of the code is to allow writing ...
8
votes
2answers
2k 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 ...
3
votes
1answer
270 views

Reverse Polish notation calculator similar to dc on Unix/Linux systems using dynamic libraries

This problem is using dynamic libraries so that additional calculator functions can be added by dropping a library into a specific directory. What I'd like to get out of this code review is: What do ...
7
votes
2answers
516 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 ...
3
votes
2answers
64 views

Constraining stdin in Python, v2.0

Rags, again. This is the rewrite of Read stdin like a dictator. From that post: All too often I find myself wanting to allow only a certain list of characters to be written to stdin, and only ...
4
votes
2answers
9k 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 ...
0
votes
2answers
436 views

BMP writer in C

I recently wrote a BMP writer in C: bmpWriter.h ...
3
votes
1answer
87 views

Non-curses pager in C (revision 2)

In this revision (follow-up of this post) I've fixed reading from stdin, and also tried to minimise the damage caused by typing additional characters. You might want to see my original post on this. <...
1
vote
0answers
52 views

Check if page was scrolled all the way to the end

I am not sure if this is the best way of doing this or if it works in all situations. ...
5
votes
2answers
65 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: ...
6
votes
1answer
76 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 ...
0
votes
1answer
149 views

Print a “shebang” line, or prepend it to a file

This is a sort-of-useless "utility" I wrote to learn my way around shell programming better. My concerns are: Is the code readable? Could it be more efficient, or just simpler? The logic ends up ...
3
votes
2answers
3k 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 ...
7
votes
2answers
69 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. ...
15
votes
1answer
211 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. ...
6
votes
1answer
778 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 ...
3
votes
1answer
138 views

Userscript hiding boxes on LinkedIn

When looking at people you may know on LinkedIn (requires you to be logged in) there are sometimes some annoying boxes that are for people who are email contacts but not on LinkedIn. I don't want to ...
11
votes
2answers
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 ...
6
votes
3answers
402 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 ...
8
votes
1answer
315 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 ...
2
votes
3answers
346 views

Simple and safe file reader for C

As an exercise to improve my coding ability in C, I have attempted to write a simple and safe file reader. I believe this should be portable as well to major platforms (correct me if I'm wrong). For ...
10
votes
4answers
7k 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 (...
3
votes
3answers
1k views

More portable toLower() implementation

I am challenging myself to try to attempt to write a function that is as efficient, portable and failsafe as possible. The function is very simple and just converts a ...
0
votes
3answers
84 views

Data-entry keypads for entering addresses

This was a little app I wrote looking for a way to create consistency in the way employees taking phone orders enter the address. The purpose of the app is to require a user to enter a valid address....
8
votes
2answers
2k 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 ...
1
vote
1answer
264 views

Load stylesheet for “rem” value fallback to “px”

I'm applying fallbacks to rem values only if required (you know, the whole progressive enhancement train), without conditional comments (because it's not just an IE ...
8
votes
2answers
175 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 ...
6
votes
2answers
104 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 ...