linkage

const variables in header file and static initialization fiasco

大城市里の小女人 提交于 2019-12-03 07:20:50
问题 After reading a lot of the questions regarding initialization of static variables I am still not sure how this applies to const variables at namespace level. I have kind of the following code in a header file config.h generated by the build script: static const std::string path1 = "/xyz/abc"; static const std::string path2 = "/etc"; According to what I have read the static keyword is not necessary, even deprecated here. My Question: Is the code above prone to the static initialization fiasco?

Dependency Property dependent on another

橙三吉。 提交于 2019-12-03 05:42:23
问题 How can one register a dependency property whose value is calculated using the value of another dependency property? Because the .NET property wrappers are bypassed by WPF at run-time, one should not include logic in the getters and setters. The solution to that is typically to use PropertyChangedCallback s. But those are declared static. For example, what is the proper way to accomplish this contrived task: public bool TestBool { get { return (bool)GetValue(TestBoolProperty); } set {

What does mean for a name or type to have a certain language linkage?

≯℡__Kan透↙ 提交于 2019-12-03 05:31:35
问题 According to (c) ANSI ISO/IEC 14882:2003, page 127: Linkage specifications nest. When linkage specifications nest, the innermost one determines the language. A linkage specification does not establish a scope. A linkage-specification shall occur only in namespace scope (3.3). In a linkage-specification, the specified language linkage applies to the function types of all function declarators, function names, and variable names introduced by the declaration(s). extern "C" void f1(void(*pf)(int)

Static functions declared in “C” header files

╄→гoц情女王★ 提交于 2019-12-03 04:52:00
For me it's a rule to define and declare static functions inside source files, I mean .c files. However in very rare situations I saw people declaring it in the header file. Since static functions have internal linkage we need to define it in every file we include the header file where the function is declared. This looks pretty odd and far from what we usually want when declaring something as static. On the other hand if someone naive tries to use that function without defining it the compiler will complaint. So in some sense is not really unsafe to do this even sounding strange. My questions

About inconsistent dll linkage

隐身守侯 提交于 2019-12-03 04:13:19
How can I remove this link warning? You can see code segment that causes this warning. static AFX_EXTENSION_MODULE GuiCtrlsDLL = { NULL, NULL }; //bla bla // Exported DLL initialization is run in context of running application extern "C" void WINAPI InitGuiCtrlsDLL() { // create a new CDynLinkLibrary for this app new CDynLinkLibrary(GuiCtrlsDLL); // nothing more to do } warning C4273: 'InitGuiCtrlsDLL' : inconsisten t dll linkage I have also export and import definitions, like: #ifdef _GUICTRLS #define GUI_CTRLS_EXPORT __declspec(dllexport) #else #define GUI_CTRLS_EXPORT __declspec(dllimport)

Dependency Property dependent on another

萝らか妹 提交于 2019-12-02 20:20:08
How can one register a dependency property whose value is calculated using the value of another dependency property? Because the .NET property wrappers are bypassed by WPF at run-time, one should not include logic in the getters and setters. The solution to that is typically to use PropertyChangedCallback s. But those are declared static. For example, what is the proper way to accomplish this contrived task: public bool TestBool { get { return (bool)GetValue(TestBoolProperty); } set { SetValue(TestBoolProperty, value); TestDouble = ((value)?(100.0):(200.0)); // HERE IS THE DEPENDENCY } }

How can I prove that inline functions default to internal linkage?

狂风中的少年 提交于 2019-12-02 19:56:23
问题 How can I prove that inline functions iin class default to internal linkage? In other words/: How can I display output of internal linkage to console? EDIT: unix platform 回答1: Here is an FAQ about inline functions http://www.parashift.com/c++-faq-lite/inline-functions.html. 来源: https://stackoverflow.com/questions/4957582/how-can-i-prove-that-inline-functions-default-to-internal-linkage

What does mean for a name or type to have a certain language linkage?

淺唱寂寞╮ 提交于 2019-12-02 19:01:44
According to (c) ANSI ISO/IEC 14882:2003, page 127: Linkage specifications nest. When linkage specifications nest, the innermost one determines the language. A linkage specification does not establish a scope. A linkage-specification shall occur only in namespace scope (3.3). In a linkage-specification, the specified language linkage applies to the function types of all function declarators, function names, and variable names introduced by the declaration(s). extern "C" void f1(void(*pf)(int)); // the name f1 and its function type have C language // linkage; pf is a pointer to a C function

scipy.cluster.hierarchy: labels seems not in the right order, and confused by the value of the vertical axes

孤街浪徒 提交于 2019-12-02 18:25:19
问题 I know that scipy.cluster.hierarchy focused on dealing with the distance matrix. But now I have a similarity matrix... After I plot it by using Dendrogram, something weird just happens. Here is the code: similarityMatrix = np.array(([1,0.75,0.75,0,0,0,0], [0.75,1,1,0.25,0,0,0], [0.75,1,1,0.25,0,0,0], [0,0.25,0.25,1,0.25,0.25,0], [0,0,0,0.25,1,1,0.75], [0,0,0,0.25,1,1,0.75], [0,0,0,0,0.75,0.75,1])) here is the linkage method Z_sim = sch.linkage(similarityMatrix) plt.figure(1) plt.title(

scipy.cluster.hierarchy: labels seems not in the right order, and confused by the value of the vertical axes

本秂侑毒 提交于 2019-12-02 11:07:55
I know that scipy.cluster.hierarchy focused on dealing with the distance matrix. But now I have a similarity matrix... After I plot it by using Dendrogram, something weird just happens. Here is the code: similarityMatrix = np.array(([1,0.75,0.75,0,0,0,0], [0.75,1,1,0.25,0,0,0], [0.75,1,1,0.25,0,0,0], [0,0.25,0.25,1,0.25,0.25,0], [0,0,0,0.25,1,1,0.75], [0,0,0,0.25,1,1,0.75], [0,0,0,0,0.75,0.75,1])) here is the linkage method Z_sim = sch.linkage(similarityMatrix) plt.figure(1) plt.title('similarity') sch.dendrogram( Z_sim, labels=['1','2','3','4','5','6','7'] ) plt.show() But here is the outcome