portability

Mac and Windows compatible GUI for Python, which is easy to install and works with pygame?

隐身守侯 提交于 2019-12-01 04:51:54
问题 I have made a program that finds and measures the radius of yeast colonies in images. It uses pygame for pixel access and graphical display of the images. The next step is to make it "user friendly" so that the non-programmers in my university bio lab can use it. Pygame lacks scroll bars, text fields, "open file" dialogues, etc., which I will need. I have heard that it's a nightmare trying to mix pygame and Tkinter. What can I use? An additional requirement is that I want the set up of Python

Alternate way of computing size of a type using pointer arithmetic

吃可爱长大的小学妹 提交于 2019-12-01 04:08:27
Is the following code 100% portable? int a=10; size_t size_of_int = (char *)(&a+1)-(char*)(&a); // No problem here? std::cout<<size_of_int;// or printf("%zu",size_of_int); P.S : The question is only for learning purpose. So please don't give answers like Use sizeof() etc Nordic Mainframe From ANSI-ISO-IEC 14882-2003, p.87 (c++03): "75) Another way to approach pointer arithmetic is first to convert the pointer(s) to character pointer(s): In this scheme the integral value of the expression added to or subtracted from the converted pointer is first multiplied by the size of the object originally

Declaring fixed-size integer typedef in Standard C

蹲街弑〆低调 提交于 2019-12-01 03:53:56
问题 Is there a reliable way to declare typedefs for integer types of fixed 8,16,32, and 64 bit length in ISO Standard C? When I say ISO Standard C, I mean that strictly: ISO C89/C90, not C99. No headers not defined in the ISO standard. No preprocessor symbols not defined in the ISO standard. No type-size assumptions not specified in the ISO standard. No proprietary vendor symbols. I see other questions similar to this in StackOverflow, but no answers yet that do not violate one of the above

Using snprintf in a cross-platform application

佐手、 提交于 2019-12-01 03:27:39
I am writing a C program that is expected to be compiled with all major compilers. Currently I am developing on GCC on a linux machine and will compile on MSVC before committing the code. To make the cross-compiling easy, I am compiling with -ansi and -pedantic flags. This worked well until I started using snprintf which is not available in C89 standard. GCC can compile this without the -ansi switch but MSVC will fail always as it doesn't have C99 support. So I did something like, #ifdef WIN32 #define snprintf sprintf_s #endif This works well because snprintf and sprintf_s has same signatures.

Using Powershell to Print a Folder of Text files to PDF (Retaining the Original Base name)

大兔子大兔子 提交于 2019-12-01 01:29:06
First time posting - but I think this is a good one as I've spent 2 days researching, talked with local experts, and still haven't found this done. Individual print jobs must be regularly initiated on a large set of files (.txt files), and this must be converted through the print job to a local file (i.e. through a PDF printer) which retains the original base name for each file. Further, the script must be highly portable. The objective will not be met if the file is simply converted (and not printed), the original base file name is not retained, or the print process requires manual

Alternate way of computing size of a type using pointer arithmetic

允我心安 提交于 2019-12-01 00:36:20
问题 Is the following code 100% portable? int a=10; size_t size_of_int = (char *)(&a+1)-(char*)(&a); // No problem here? std::cout<<size_of_int;// or printf("%zu",size_of_int); P.S : The question is only for learning purpose. So please don't give answers like Use sizeof() etc 回答1: From ANSI-ISO-IEC 14882-2003, p.87 (c++03): "75) Another way to approach pointer arithmetic is first to convert the pointer(s) to character pointer(s): In this scheme the integral value of the expression added to or

Does an empty string contain an empty string in C++?

℡╲_俬逩灬. 提交于 2019-11-30 23:47:45
Just had an interesting argument in the comment to one of my questions. My opponent claims that the statement "" does not contain "" is wrong. My reasoning is that if "" contained another "" , that one would also contain "" and so on. Who is wrong? P.S. I am talking about a std::string P.S. P.S I was not talking about substrings, but even if I add to my question " as a substring", it still makes no sense. An empty substring is nonsense . If you allow empty substrings to be contained in strings, that means you have an infinity of empty substrings. What is the point of that? Edit: Am I the only

How to split file on first empty line in a portable way in shell (e.g. using sed)?

こ雲淡風輕ζ 提交于 2019-11-30 23:04:17
问题 I want to split a file containg HTTP response into two files: one containing only HTTP headers, and one containg the body of a message. For this I need to split a file into two on first empty line (or for UNIX tools on first line containing only CR = ' \r ' character) using a shell script . How to do this in a portable way (for example using sed , but without GNU extensions)? One can assume that empty line would not be first line in a file. Empty line can got to either, none or both of files;

C - get type alignment portably

北慕城南 提交于 2019-11-30 20:43:22
I'm writing really small interpreter for a very simple language, which allows for simple structure definitions (made of other structures and simple types, like int, char, float, double and so one). I want fields to use as little alignment as possible, so using max_align_t or something similar is out of question. Now, I wonder if there is a nicer way to get alignment of any single type other than this: #include <stdio.h> #include <stddef.h> #define GA(type, name) struct GA_##name { char c; type d; }; \ const unsigned int alignment_for_##name = offsetof(struct GA_##name, d); GA(int, int); GA

How un-portable is assembly language, /really/?

纵然是瞬间 提交于 2019-11-30 20:40:50
I understand that writing anything in assembly, or adding assembly to any program harms its portability. But, how bad? I mean, basically all PC's are x86 or x64 these days, right? So, if I embed assembly into a C program, why wouldn't it still compile no matter where it went? Does this notion of un-portability just refer to when you really dig in to the specific quirks of a specific processor, to squeeze out every drop of performance from a piece of code? The PC game "Roller Coaster Tycoon" was written almost entirely in assembly language if I remember correctly. So... How un-portably could it