portability

How can I creating executable JAR with SWT that runs on all platforms?

邮差的信 提交于 2019-11-27 01:54:41
问题 SWT comes with a base JAR and one specific JAR per platform (Windows, Linux/32bit, Linux/64bit, Mac, AIX, ...). How can I create an executable JAR that will select the correct platform JAR at runtime? [EDIT] I was thinking to supply all platform JARs in a subdirectory and in main() would then modify the class loader. Has anyone already tried this? 回答1: Look at this, there is a code sample: Create cross platform java swt application 回答2: For my current job I needed to supply an executable jar

How to use printf to display off_t, nlink_t, size_t and other special types?

半城伤御伤魂 提交于 2019-11-27 01:41:21
In my program, I stat the files they want and send the data over. The fields of a stat struct are all special types: struct stat { dev_t st_dev; /* ID of device containing file */ ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of owner */ gid_t st_gid; /* group ID of owner */ dev_t st_rdev; /* device ID (if special file) */ off_t st_size; /* total size, in bytes */ blksize_t st_blksize; /* blocksize for file system I/O */ blkcnt_t st_blocks; /* number of 512B blocks allocated */ time_t st_atime; /* time of

How to convert a simple .Net console project a into portable exe with Mono and mkbundle?

烂漫一生 提交于 2019-11-27 01:37:38
I'd like to convert my simple pure .Net 2.0 console utility into a portable exe which I could just put on an USB stick and run without having to worry whether the CLR and framework libraries are installed on a particular machine or not. Stackoverflow already has some information on using Mono and Mkbundle for creating self-contained Windows exes from .Net-projects, but what I would like to have is a compact but useful HOWTO. What are the minimum steps for achieving a portability from a simple C# Visual Studio project? I have found a simple how-to here , however, as I have not tested it myself,

Building a 32-bit float out of its 4 composite bytes

筅森魡賤 提交于 2019-11-27 01:27:27
I'm trying to build a 32-bit float out of its 4 composite bytes. Is there a better (or more portable) way to do this than with the following method? #include <iostream> typedef unsigned char uchar; float bytesToFloat(uchar b0, uchar b1, uchar b2, uchar b3) { float output; *((uchar*)(&output) + 3) = b0; *((uchar*)(&output) + 2) = b1; *((uchar*)(&output) + 1) = b2; *((uchar*)(&output) + 0) = b3; return output; } int main() { std::cout << bytesToFloat(0x3e, 0xaa, 0xaa, 0xab) << std::endl; // 1.0 / 3.0 std::cout << bytesToFloat(0x7f, 0x7f, 0xff, 0xff) << std::endl; // 3.4028234 × 10^38 (max single

Change the current working directory in C++

南笙酒味 提交于 2019-11-27 01:24:35
How can I change my current working directory in C++ in a platform-agnostic way? I found the direct.h header file, which is Windows compatible, and the unistd.h , which is UNIX/POSIX compatible. The chdir function works on both POSIX ( manpage ) and Windows (called _chdir there but an alias chdir exists). Both implementations return zero on success and -1 on error. As you can see in the manpage, more distinguished errno values are possible in the POSIX variant, but that shouldn't really make a difference for most use cases. For C++, boost::filesystem::current_path (setter and getter prototypes

Checking the gcc version in a Makefile?

怎甘沉沦 提交于 2019-11-27 01:19:00
问题 I would like to use some gcc warning switchs that aren't available in older gcc versions (eg. -Wtype-limits). Is there an easy way to check the gcc version and only add those extra options if a recent gcc is used ? 回答1: I wouldn't say its easy, but you can use the shell function of GNU make to execute a shell command like gcc --version and then use the ifeq conditional expression to check the version number and set your CFLAGS variable appropriately. Here's a quick example makefile: CC = gcc

Portability of binary serialization of double/float type in C++

房东的猫 提交于 2019-11-27 00:44:42
The C++ standard does not discuss the underlying layout of float and double types, only the range of values they should represent. (This is also true for signed types, is it two's compliment or something else) My question is: What the are techniques used to serialize/deserialize POD types such as double and float in a portable manner? At the moment it seems the only way to do this is to have the value represented literally(as in "123.456"), The ieee754 layout for double is not standard on all architectures. Brian "Beej Jorgensen" Hall gives in his Guide to Network Programming some code to pack

How can I have a portable Emacs?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 23:59:41
问题 Is there a way run Emacs from a USB drive? I am a Windows user and I would like to be able use it on any PC without an Emacs install. 回答1: Yes, the "normal" Emacs distribution for Windows is precompiled and just runs without having to do any install. Just get one of the *.zip files from the usual place, unpack it onto a USB disk, and you can use it directly. (The actual binary is inside the "bin/" directory.) The only thing you may want to do is set it up to look for ".emacs" always on the

How to Declare a 32-bit Integer in C

≯℡__Kan透↙ 提交于 2019-11-26 22:51:48
问题 What's the best way to declare an integer type which is always 4 byte on any platforms? I don't worry about certain device or old machines which has 16-bit int . 回答1: #include <stdint.h> int32_t my_32bit_int; 回答2: C doesn't concern itself very much with exact sizes of integer types, C99 introduces the header stdint.h , which is probably your best bet. Include that and you can use e.g. int32_t . Of course not all platforms might support that. 回答3: Corey's answer is correct for "best", in my

Free portable database [closed]

只谈情不闲聊 提交于 2019-11-26 22:50:51
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Hi I am developing desktop portable free application and I`m looking for portable database: free without install up to 20K records standalone application supports encryption (optional) SQL92 spec thanks for advice can you write some advantages and disadvangtages? 回答1: SQLite: self-contained, serverless, zero