initialization

initialize jmockit without -javaagent

隐身守侯 提交于 2021-01-28 05:05:06
问题 I use jmockit and junit to write unit test for a module and run it in a STB. I use jmockit-1.7 because the STB only have java 5. I got this error when run unit test: java.lang.IllegalStateException: Jmockit has not been initialized. Check that your Java 5 VM has been started with -javaagent:jmockit.jar command line option but my STB use siege java VM, so it doesn't have -javaagent command line option I have google, and found a solution from Running tests with JMockit @BeforeClass public

initialize jmockit without -javaagent

ぐ巨炮叔叔 提交于 2021-01-28 05:04:30
问题 I use jmockit and junit to write unit test for a module and run it in a STB. I use jmockit-1.7 because the STB only have java 5. I got this error when run unit test: java.lang.IllegalStateException: Jmockit has not been initialized. Check that your Java 5 VM has been started with -javaagent:jmockit.jar command line option but my STB use siege java VM, so it doesn't have -javaagent command line option I have google, and found a solution from Running tests with JMockit @BeforeClass public

cl x64: unsigned long outside / inside union: error C2099: initializer is not a constant / NO error

老子叫甜甜 提交于 2021-01-27 19:50:17
问题 Case 1. File: test1.c : unsigned long val = (unsigned long)&"test"; int main() { return 0; } Compiler invocation: cl test1.c /c Results: Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28611 for x64 Copyright (C) Microsoft Corporation. All rights reserved. test1.c test1.c(1): warning C4311: 'type cast': pointer truncation from 'char (*)[5]' to 'unsigned long' test1.c(1): error C2099: initializer is not a constant Case 2. File: test2.c : union { unsigned long val; } val = { (unsigned

cl x64: unsigned long outside / inside union: error C2099: initializer is not a constant / NO error

天涯浪子 提交于 2021-01-27 19:20:26
问题 Case 1. File: test1.c : unsigned long val = (unsigned long)&"test"; int main() { return 0; } Compiler invocation: cl test1.c /c Results: Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28611 for x64 Copyright (C) Microsoft Corporation. All rights reserved. test1.c test1.c(1): warning C4311: 'type cast': pointer truncation from 'char (*)[5]' to 'unsigned long' test1.c(1): error C2099: initializer is not a constant Case 2. File: test2.c : union { unsigned long val; } val = { (unsigned

What do curly braces after a struct variable member mean?

不打扰是莪最后的温柔 提交于 2021-01-27 10:09:52
问题 During some maintenance (Valgrind'ing) I came across this code: #pragma pack(push, 1) struct somename { uint16_t a{}; uint16_t b{}; uint32_t c{}; }; #pragma pack(pop) I would expect that the {} tell the compiler to always initialize the values to 0 (when allocating using new, or using a stack variable), but I cannot find any examples or documentation on that. Am I correct in this assumption? If not: What do the curly braces {} after a struct member variable mean? 回答1: This is default member

What do curly braces after a struct variable member mean?

隐身守侯 提交于 2021-01-27 10:09:51
问题 During some maintenance (Valgrind'ing) I came across this code: #pragma pack(push, 1) struct somename { uint16_t a{}; uint16_t b{}; uint32_t c{}; }; #pragma pack(pop) I would expect that the {} tell the compiler to always initialize the values to 0 (when allocating using new, or using a stack variable), but I cannot find any examples or documentation on that. Am I correct in this assumption? If not: What do the curly braces {} after a struct member variable mean? 回答1: This is default member

static global variables initialization order

喜欢而已 提交于 2021-01-27 06:59:09
问题 In many of the answers that I found here were said the following words: Global variables in a single translation unit (source file) are initialized in the order in which they are defined. or Within the same compilation unit the order is well defined: The same order as definition. etc. But where can I see these words in the standard of C++? I would like to get a one or few concrete paragraph's where such behavior is described. I can not find it myself, and I do not know who to ask. 回答1: 6.6.3

Why are x86-64 C/C++ compilers not generating more efficient assembly for this code?

老子叫甜甜 提交于 2021-01-27 05:57:14
问题 Consider the following declaration of local variables: bool a{false}; bool b{false}; bool c{false}; bool d{false}; bool e{false}; bool f{false}; bool g{false}; bool h{false}; in x86-64 architectures, I'd expect the optimizer to reduce the initialization of those variables to something like mov qword ptr [rsp], 0 . But instead what I get with all the compilers (regardless of level of optimization) I've been able to try is some form of: mov byte ptr [rsp + 7], 0 mov byte ptr [rsp + 6], 0 mov

Why are x86-64 C/C++ compilers not generating more efficient assembly for this code?

别来无恙 提交于 2021-01-27 05:55:45
问题 Consider the following declaration of local variables: bool a{false}; bool b{false}; bool c{false}; bool d{false}; bool e{false}; bool f{false}; bool g{false}; bool h{false}; in x86-64 architectures, I'd expect the optimizer to reduce the initialization of those variables to something like mov qword ptr [rsp], 0 . But instead what I get with all the compilers (regardless of level of optimization) I've been able to try is some form of: mov byte ptr [rsp + 7], 0 mov byte ptr [rsp + 6], 0 mov

'non-static reference member, can't use default assignment operator'

别说谁变了你拦得住时间么 提交于 2021-01-22 12:13:49
问题 I get this error when i try to compile my code: non-static reference member ‘Timestep& Timestep::previousTimestep’, can’t use default assignment operator I create one Problem which creates a Timestep a reference to the this Timestep should be stored in the vector solution . Besides i want to store a reference to a previous Timestep - and for the first Timestep that would be a reference to itself... I read that i need to define an own operator if i have const members in a class what i try to