portability

How to avoid integer promotion in C?

冷暖自知 提交于 2019-12-12 06:52:39
问题 It is not clear how to write portable code in C, using wide-character API. Consider this example: #include <locale.h> #include <wchar.h> #include <wctype.h> int main(void) { setlocale(LC_CTYPE, "C.UTF-8"); wchar_t wc = L'ÿ'; if (iswlower(wc)) return 0; return 1; } Compiling it with gcc-6.3.0 using -Wconversion option gives this warning: test.c: In function 'main': test.c:9:16: warning: conversion to 'wint_t {aka unsigned int}' from 'wchar_t {aka int}' may change the sign of the result [-Wsign

Mac OS X Archive (.app) crashed on test Mac machine: EXC_BAD_INSTRUCTION

Deadly 提交于 2019-12-12 03:30:01
问题 I am working on a Mac application, which is running fine on my machine which is a development machine. The project has quite a few dylib files, the dependancies for which I had to solve using install_name_tool -change I used @executable_path in the above command. After doing this, the program works fine on my machine, when I move the .app file to test environment it fails.. Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes:

Is it safe to use Bash 4 features in news scripts?

喜你入骨 提交于 2019-12-12 02:57:02
问题 Bash4 offers some nice features like globstar, associative arrays, the mapfile builtin etc. Will it greatly decrease the portability of my scripts if I make use of these features? Is it safer to stick to Bash 3? 回答1: Depends on how portable you want to be. Apple does not ship Bash 4 on Mac OS X since Bash 4 uses the GPLv3. Of course, users can install it themselves if they want, but most users won't have it. If you want to be portable to OS X, you probably shouldn't rely on Bash 4 features.

Bit fields in a union - how portable is this?

送分小仙女□ 提交于 2019-12-12 01:11:14
问题 I got a bit field with a bunch of flags, and I need a quick and dirty way to set everything to zero, so instead of blindly casting the struct to an integer, I decided it would be "better" to put the bit fields in a union with an actual integer. union Flags { uint _all; struct { uint status : 2; uint expanded : 1; uint draw : 1; uint drawChildren : 1; uint hidden : 1; uint disabled : 1; uint used : 1; uint deletable : 1; uint incomplete : 1; uint isStatic : 1; uint isConst : 1; uint isVolatile

is it good practice to create functions which use other functions that you built?

霸气de小男生 提交于 2019-12-11 13:59:09
问题 Is it good practice to create functions which use other functions that you built? I was wondering if it was good to have this since it makes code less portable. Thanks 回答1: Very good practice. It is called code reuse and this is what programming is all about. As for your argument about it making "code less portable", that only makes sense in a very low level language such as assembly, and even then it makes it more portable as you can isolate platform specific code into functions. Good code

Portability of Array.prototype.* on array like objects or ever native/host objects

谁说我不能喝 提交于 2019-12-11 13:26:49
问题 ESMA 262 5.1 for many Array.prototype functions say that they are intentionally generic and described in terms of [[Get]] , [[Put]] , etc operations on Object , but also require length property. So them allowed to work on build-in objects, like: obj = {"a":true, "length":10}; Array.prototype.push.call(obj, -1); console.log(obj); // Object { 10: -1, a: true, length: 11 } For native objects standard have note: Whether the push function can be applied successfully to a host object is

Is there a portable python interpreter that will run on Mac OS X 10.6 from a USB key?

大憨熊 提交于 2019-12-11 11:06:48
问题 I've been running myself ragged trying to find a portable interpreter that I can run from a USB key on my work computer. Work comp is running Mac OS X 10.6, fairly restricted environment, no access to terminal, can't install apps but I do know that portable apps can be run from a USB drive. I've been using shell in a box to serve remote access to my comp at home over the web but out of respect for their network integrity I'd prefer not to. I've also just come across ideone.com which seems

directly execute binary resource

时光毁灭记忆、已成空白 提交于 2019-12-11 08:55:03
问题 lpBuffer is a pointer to the first byte of a (binary)resource. How can I execute it straight away without dumping it to a temporary file? HMODULE hLibrary; HRSRC hResource; HGLOBAL hResourceLoaded; LPBYTE lpBuffer; hLibrary = LoadLibrary("C:\\xyz.exe"); if (NULL != hLibrary) { hResource = FindResource(hLibrary, MAKEINTRESOURCE(104), RT_RCDATA); if (NULL != hResource) { hResourceLoaded = LoadResource(hLibrary, hResource); if (NULL != hResourceLoaded) { lpBuffer = (LPBYTE) LockResource

Portable JVM with jar

邮差的信 提交于 2019-12-11 08:45:07
问题 Is it possible to pack a JVM or JRE with a jar file so that assuming the user does or doesn't have Java installed, it will always resort to the packed JVM. My guess is that it would require some sort of c/c++ program which would take away the multi platform aspect of java. This is fine, as long as the platform is Windows. Also it would be best if the user doesn't get a prompt to install the JVM, the program just launches it and then the application with no prompt for the user to install

Xerces-c and cross-platform string literals

好久不见. 提交于 2019-12-11 07:48:23
问题 I'm porting a code-base that uses Xerces-c for XML processing from Windows/VC++ to Linux/G++. On Windows, Xerces-c uses wchar_t as the character type XmlCh . This has allowed people to use std::wstring and string literals of L"" syntax. On Linux/G++, wchar_t is 32-bit and Xerces-c uses unsigned short int (16-bit) as the character type XmlCh . I've started out along this track: #ifdef _MSC_VER using u16char_t = wchar_t; using u16string_t = std::wstring; #elif defined __linux using u16char_t =