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.
103
questions
2
votes
1
answer
43
views
Finding the Size of a File in a Portable Manner (revision 2)
This is a follow up to Find the Size of a File in a Portable Manner (revision).
Changes made:
The return value of fseek() and ...
4
votes
2
answers
81
views
Find the Size of a File in a Portable Manner (revision)
This is a follow up to Find the Size of a File in a Portable Manner.
What's new:
The fast version (POSIX stat()) does not change the position indicator of the ...
7
votes
2
answers
688
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 ...
4
votes
2
answers
104
views
TCP socket base class and Winsock implementation
I'm coding a chat application from scratch in modern C++. I'm currently building an interface for interacting with sockets. I want it to be cross platform. Am I approaching platform independence ...
2
votes
2
answers
148
views
A small header-only input output library
The library (inspired by stb libraries) attempts to provide some commonly used functions (reading a file into memory, determining the size of a file) that are missing from the C standard library ...
3
votes
2
answers
102
views
Unpacking a byte into 8 bytes, where the LSB of each byte corresponds to a bit of the original byte
I needed to unpack a byte into the LSBs of each byte in an 8-byte integer. After some testing, I derived a surprisingly efficient and elegant solution that uses magic numbers multiplication, though ...
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.
...
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 ...
3
votes
3
answers
686
views
Command line calculator in C
This code is an arithmetic parser as is the code in a previous question of mine. However this parser handles floating point arguments and mathematical functions, and handles them without needing to ...
4
votes
1
answer
729
views
Basic recursive descent parser in C
The purpose of this code is to evaluate simple integer expressions that make use of the C arithmetic and bitwise operators while respecting C operator precedence and parenthesis. I wrote this code ...
4
votes
1
answer
182
views
Vectorized 16-bit addition in Standard C
The idea is to add a given 16-bit number N to each element of an array of 16-bit integers of arbitrary length, taking advantage of 64-bit integer types and instructions to perform the additions 4 at a ...
3
votes
1
answer
415
views
Portable integer to/from little endian conversion in C
Integers need to be converted to a byte array of defined endianness to be reliably and consistently saved and transmitted, and converted back to be accurately received and read. The goal is to be as ...
2
votes
0
answers
113
views
A Python base class for a family of Postgres server manager classes
I'm working on a repo the purpose of which is to create and manage a local PostGIS server. (PostGIS is a bit niche, but it boils down to a few extra spatial data types and built-in SQL function. With ...
1
vote
1
answer
289
views
File Abstraction Library
This library is a layer of abstraction over file operations in C#. It aims to provide easy file IO syntax, and implicit error handling behaviors, to ensure robustness in scenarios including, but not ...
2
votes
1
answer
187
views
Portable noreturn in C/C++ between compilers
I'm writing a C/C++ (intended to also be valid C code) for having a noreturn macro variable as widely portable as possible between C and C++ compilers.
...