standards

How can I prevent a nameless struct\\union?

有些话、适合烂在心里 提交于 2019-12-04 07:26:52
I am building a class that has a union for its matrix data, however, I can only get it compile when I do not have a name for the struct\union. However, with a higher level warning level (four on visual studio) I will a warning saying warning C4201: nonstandard extension used : nameless struct/union I looked into it, and I don't seem to be able to find a way to prevent this. Anyway possible that I know of will cause a different compiler error related to the declaration of one or the other. How can I prevent getting this warning and make it conform to standards, without just disabling the

GREATEST and LEAST in SQL standard

别等时光非礼了梦想. 提交于 2019-12-04 07:21:38
My understanding is that GREATEST() and LEAST() are not part of the SQL standard, but are very common. I'm wondering, is there a way to clone the functionality of GREATEST keeping within the SQL standard? SELECT id, GREATEST(1,2,3,4,5,6,7) AS number FROM table The fully query: SELECT SUBSTR(section,1,2) AS campus, AVG(GREATEST(maximum - enrolled, 0)) AS empty FROM sectionrun WHERE coursenumber = '105' AND subject = 'ENGL' GROUP BY campus You can use the CASE expression: SELECT SUBSTR(section,1,2) AS campus, AVG(CASE WHEN maximum - enrolled > 0 THEN maximum - enrolled ELSE 0 END) AS empty FROM

Is iteration slower than linear code? Which one is preferable?

心已入冬 提交于 2019-12-04 07:06:23
问题 This question was migrated from Software Engineering Stack Exchange because it can be answered on Stack Overflow. Migrated 7 years ago . I have a question in my mind from last many days, that while writing a code in ruby, is the linear code is faster and preferable than an iteration? Let me have an example. There is a block of code for same functionality written in two different ways: Way 1: ['dog', 'cat', 'tiger'].each do |pet_name| puts "I have many pets, one of them is #{pet_name}." end

Which version of C++ library on Linux conform to the “ISO C++ 11” standard?

≯℡__Kan透↙ 提交于 2019-12-04 07:03:29
Presently I've Debian Squeeze(AMD64 linux), libstdc++5 and libstdc++6 on my computer. Do these C++ libraries conform to the ISO standard C++11? No they don't conform fully, but they have elements : C++11 support on stdlibc++ (this is for the latest version, not the one you have) C++11 support on GCC versions Your best bet is to try libc++ (developed for clang but works with GCC 4.4 as well). You could try downloading and compiling the latest clang or GCC release as well. Only MS has a fully implemented C++11 library in VC 11 (or so they claim, and yes, that doesn't help you, sorry). 来源: https:

Set as default C++11 in Clang

半世苍凉 提交于 2019-12-04 06:15:07
The LLVM C++ compiler has full support for C++11 standard. Is there a way to set C++11 as the default standard without adding -std=c++11 compiler flag every time? I tried setting CCXFLAGS environment variable to -std=c++11 , but with no luck. Use clang 6.0.0 or higher. The default C++ dialect is now C++14. http://releases.llvm.org/6.0.1/tools/clang/docs/ReleaseNotes.html#c-language-changes-in-clang 来源: https://stackoverflow.com/questions/21581838/set-as-default-c11-in-clang

Why are structs not allowed in equality expressions in C? [duplicate]

一笑奈何 提交于 2019-12-04 06:02:09
This question already has answers here : Closed 2 years ago . Why doesn't C provide struct comparison? (5 answers) The unavailability of structs as comparison operands is one of the more obvious things in C that don't make too much sense (to me). structs can be passed by value and copied via assignments but == is not specified for them. Below are the relevant parts of the C11 standard (draft) that define the constraints of the equality operators ( == and != ) and the simple assignment operator ( = ). Note the lack of structures and unions in the constraints of equality operators. (Apart from

Is this the correct way of putting HTML in PHP?

丶灬走出姿态 提交于 2019-12-04 04:35:18
问题 I'm new to PHP, and most of the time I have been 'echo'ing my HTML. Today, I found this way of doing it, which makes things 1000 times easier: <?php if(get_field('field_name')){ ?> <p>HTML can go here without echo'ing it</p> <?php } ?> But is it an accepted way? It seems to work every time. Thanks. 回答1: It's mostly about how you like to read your code. With IDE that has autocomplete/code suggestions it is best to use <?php if (...) { ?> so that autocompletion/suggestion features know when to

Is there a standard pointer size declaration?

霸气de小男生 提交于 2019-12-04 04:26:31
问题 I have struct with padding in char (oops, my bad). I would like to subtract a pointer size. Do you know a standard pointer size declaration, or a standard macro for that? 回答1: sizeof (void *) 回答2: Do you want the C-standard answer, or the answer that works pretty much all the time? Usually, all pointers to data are the same size, which is sizeof(void*) . But since you tagged "C" and "standards", note that this is not required by the C standard. I think it is required by POSIX, and is also

Convert double to time_t

我的未来我决定 提交于 2019-12-04 04:05:27
I have a double containing seconds. I would like to convert this into a time_t . I can't find a standard function which accomplishes this. Do I have to fill out the time_t by hand? The type of std::time_t is unspecified. Although not defined, this is almost always an integral value holding the number of seconds (not counting leap seconds) since 00:00, Jan 1 1970 UTC, corresponding to POSIX time. So, just a safe casting between them could be fine. Also be carefull about portability (because it's type is not specified in the standard) and consider about the values than can not fit while casting

how can I write an ANSI C console screen buffer?

馋奶兔 提交于 2019-12-04 03:55:48
问题 I'm working on making an ASCII based game, and everywhere I look people are saying to use Console.Write() from MSDN, which is dandy and all if you're using Windows, but I'm not. And thus, I'm trying to write a function, or group of functions in C that can alternate between two screen buffers, and write them to the screen, similar to what man pages would be like, as well as pico, vim, and emacs. I have the buffer's working, and found an old ASCII game for linux called 0verkill that uses C and