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
1
vote
1answer
37 views

Open, writing to, and closing a configuration file, and error checking the process in C

All this does is safely and reliably opens, writes to, and closes the file. Yet there are so many gotos and the code is quite verbose. I am not even sure that all ...
1
vote
0answers
50 views

C++ exception class for error reporting, compatible with C++98 through C++20 (ver 2)

This question contains revised code from the question What should a C++ error reporting exception class have to be portable across language versions?. I summarize what is different from that code at ...
8
votes
2answers
100 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 ...
0
votes
0answers
51 views

Performance discrepancy between Windows and Ubuntu for a video-memory-based virtual array implementation

I implemented virtual array using OpenCL and graphics cards as backing store, with caching some of data on RAM using a LRU algorithm and accessing data through some simple setters/getters. Accession ...
1
vote
1answer
65 views

Cross-platform console abstraction

C++ is not aware of the console and it's behaviour / features / options, only its std::cout stream. To do more than stream we need to be platform aware. Aim To ...
4
votes
1answer
37 views

Text centered in a circular component

I have surrounded my initials with a circle. This is intended to be a re-usable component in a responsive layout. (When it is re-used the text will always be two letters, and the font won't change. It ...
2
votes
1answer
58 views

*nix, *bsd, etc basic `tput` color setup

My goal with the below piece of POSIX shell code was to address the more platforms the better with shell tput colors. With this code, I now start all of my scripts, ...
2
votes
0answers
33 views

Bash script to scp specific, most-recent files from remote server

I'm writing a helper script that I wish to be able to share with my co-workers. We all work using macOS Mojave, but all have their own shell configurations. For example, I actually use ZSH and bash 5....
12
votes
1answer
189 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-...
7
votes
0answers
455 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 ...
5
votes
1answer
198 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' ...
3
votes
2answers
252 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 ...
2
votes
0answers
310 views

A portable cross platform C++17 method to retrieve the current date and time

I am working on a utility function to get the current date and time. My objective is to do this in a generic and portable way. I would like to stay way from platform specific code to allow the ...
0
votes
1answer
119 views

Polymorphism and inheritance in C99

In the following code I have created the something like the behavior of inheritance and methods in C99 (without vtable). The code compiles without any warnings even with ...
2
votes
2answers
81 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 ...
12
votes
2answers
2k 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
364 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
151 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
425 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
81 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
116 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
47 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
15k 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 ...
5
votes
1answer
320 views

Modular exponentiation without range restriction

A typical modular exponentiation may be coded using the following algorithm. ...
4
votes
3answers
733 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
241 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
207 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
2k 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
14k 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
902 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
1k 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 ...
6
votes
2answers
812 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
217 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 ...
6
votes
1answer
235 views

Correct and portable serialization

So I've made custom binary streams which work like this: ...
4
votes
1answer
70 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
498 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
1k views

Portable safe unsigned integer arithmetic

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

BMP writer in C

I recently wrote a BMP writer in C: bmpWriter.h ...
3
votes
1answer
90 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
64 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. ...
7
votes
2answers
83 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
77 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
231 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 ...
4
votes
2answers
5k 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
71 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. ...