standards

Returning a variable while using a post increment in C

巧了我就是萌 提交于 2019-12-23 08:56:08
问题 I have a global variable called var and a function foo . (I know it's a bad practice but sometimes it's unavoidable) I'm wondering if the C standard (I'm compiling using c99) says what happens to var if I try to execute: long foo(){ return var++; } Thanks. 回答1: Short answer: It will return a copy of var and then immediately afterwards increment the global var . Long answer: C11 6.5.2.4 "The result of the postfix ++ operator is the value of the operand. As a side effect, the value of the

Would it be reasonable to define destruction order of vector elements?

假如想象 提交于 2019-12-23 07:20:13
问题 I know that vector elements destruction order is not defined by C++ standard (see Order of destruction of elements of an std::vector) and I saw that all compilers I checked do this destruction from begin to end - which is quite surprising to me since dynamic and static arrays do it in reverse order, and this reverse order is quite often in C++ world. To be strict: I know that "Container members ... can be constructed and destroyed in any order using for example insert and erase member

Compile-time array constants

懵懂的女人 提交于 2019-12-23 07:13:12
问题 I seem to be missing something rather fundamental. I'm trying to use const array members at compile-time. const int list[3] = { 2, 5, 7 }; const int a = list[2]; // this doesn't error? template<int N1, int N2> struct tmax { enum { value = ((N1 > N2) ? N1 : N2) }; }; const int b = tmax<2,4>::value; const int c = tmax<list[0],list[1]>::value; // error is here int main() { return 0; } Errors: prog.cpp:10:24: error: 'list' cannot appear in a constant-expression prog.cpp:10:30: error: an array

What “standard” application return/exit codes should an application support?

好久不见. 提交于 2019-12-23 07:09:03
问题 Is there such thing as a standard set of application return codes? Things like returning 0 for success 1 for failure, and then so on? I have a Windows Server application that I am adding some return error codes and wanted to stick to standard codes in addition to the app specific ones that I will need. 回答1: There is no such thing as a standard set of exit codes that applications should conform to. However, there are some common ones like 0 for success as you mentioned. Depending on the

Storage Commitment Service (push model): how i get the result back to my SCU?

半腔热情 提交于 2019-12-22 18:36:19
问题 I planned to implement a Storage Commitment Service to verify if files previously sent to the storage were safely stored. My architecture is very simple and straightforward my SCU sends some secondary capture images to the storage and I want to be sure they are safely stored before delete them. I am going to adopt push model and I wonder what steps/features I need to implement to accomplish the service What I understood is I need to issue a N-ACTION request with SOP Class UID 1.2.840.10008.1

unary minus for 0x80000000 (signed and unsigned)

怎甘沉沦 提交于 2019-12-22 18:26:21
问题 The n3337.pdf draft, 5.3.1.8, states that: The operand of the unary - operator shall have arithmetic or unscoped enumeration type and the result is the negation of its operand. Integral promotion is performed on integral or enumeration operands. The negative of an unsigned quantity is computed by subtracting its value from 2ⁿ, where n is the number of bits in the promoted operand. The type of the result is the type of the promoted operand. For some cases it is enough. Suppose unsigned int is

An alternative to the ancient “marquee” tag?

依然范特西╮ 提交于 2019-12-22 12:09:07
问题 What is the standard equivalent of the "marquee" tag? I'm looking for a solution in HTML, C#, asp.NET or ASPX, jquery, java script 回答1: The "marquee" tag was not included in the standard because it's a "visual" tag, not a "semantic" tag. As such, none of the languages that you want have an exact equivalent. I suggest using Javascript to do animations on your webpage. (I hear that jQuery is a great framework to get started with.) Note: As someone pointed out in MSO chat, there is actually a

Error while installing SQL Server 2012 Standard Edition

拟墨画扇 提交于 2019-12-22 11:23:34
问题 Here's how the error looks while the installation: An error occurred during the setup process of the feature Attempted to perform an unauthorized operation. Clicking on Retry doesn't help, if I click on the Cancel button, it continues but then there will come up more errors like this one: NOTE: I'm not using any VM, I'm using Windows 7 Ultimate 32 bit as my OS. Here's the log details: Overall summary: Final result: Failed: see details below Exit code (Decimal): -2068119551 Start time: 2013-10

C/C++ linker order for multiple defined symbols

不想你离开。 提交于 2019-12-22 11:01:17
问题 If I have the same symbol defined in an object file and in a library the GNU linker takes the symbol from the object file. Consider this example: g++ -L"dir/to/lib" -o Executable Test.o foo.o -lMyLib If I have defined a function foo with the same signature in both foo.cpp and in a source file "MyLib" was compiled from, the GNU linker always prefers the one from the former if I use this order. Is this behaviour GNU toolchain specific? Do you know from other linkers that behave the same way? Is

Alignment of char array struct members in C standard

隐身守侯 提交于 2019-12-22 09:36:14
问题 Let us suppose I would like to read/write a tar file header. Considering standard C (C89, C99, or C11), do char arrays have any special treatment in structs, regarding padding? Can the compiler add padding to such a struct: struct header { char name[100]; char mode[8]; char uid[8]; char gid[8]; char size[12]; char mtime[12]; char chksum[8]; char typeflag; char linkname[100]; char tail[255]; }; I've seen it used in code on the web as well. Just freading, fwriting this struct to the file in one