Questions tagged [static]

14516 questions
1

votes
1

answer
154

Views

Function calling at the left side of the expression

Can we have a function calling at the left side of the expression? This code snippet works well but how? How can a function calling can be at left side and please elaborate how this snippet is executing and working well and what if i wouldn't have used static int in function definition.Thanks in adv...
Shivanshu
1

votes
1

answer
42

Views

Embedded C: Can I pass members of a static struct to function in another file, IF a pointer to the member is passed by a fn in the same file

I have a struct like this: typedef struct { uint8_t var_1; uint8_t var_2; }TYPE_struct_variables; static TYPE_struct_variables variables; For argument sake, I want to pass one of the members in this struct down another layer towards the metal. For this example, this is a data struct for an external...
Medicineman25
1

votes
2

answer
43

Views

static uint8_t variable changes to incorrect value when using += on Mac

I had a colleague today ask me a question regarding his code that I could not answer. He is writing a C unit test on Mac that makes use of a static uint8_t variable (initialized to 0) for holding the current read position from a test buffer across invocations of a seemingly simple read function in t...
Michael Cress
1

votes
3

answer
24

Views

Read attribute value of derived class

I'm building the app which will work with SQLite and what I want to do now is to get table creation strings for each entity which should be stored with code like this: table_creation_string1 = Book.GetTableCreationString(); table_creation_string2 = Scroll.GetTableCreationString(); Which will allow m...
0

votes
0

answer
3

Views

How to serve two static sites with gin in golang?

I want to create an application that will call a boolean function and depending on the result provide 1 of 2 compiled react apps as static sites. I'm using the LoadHTMLGlob function recommended by gin and it works fine with .tmpl files like the example in thier docs. However when doing just static h...
Jbar
2

votes
1

answer
36

Views

Why does std::is_nothrow_move_constructible return false with user-declared move constructor?

everyone. I'm trying to add noexcept specifications and static_asserts to my class. To accomplish this goal I've made a small research on how std::is_nothrow_move_constructible works. I've got strange results: std::is_nothrow_move_constructible::value for a class A with only default-constructor decl...
Arks
1

votes
2

answer
4.3k

Views

PHP: Call an internal (Function) method within the same class

Rather than having multiple lines of the same code on each method, I want to set up a (Boot/initialization) method to define common values and such. Then, call that method when needed. Initially, I had something like this: But I would get an error saying something like: Parse error: syntax error, un...
Omar
1

votes
1

answer
542

Views

Getting Screen Size in Java as a Statric Variable [duplicate]

This question already has an answer here: Get effective screen size from Java 4 answers I am fairly new to Java so this probably has a simple solution but I just can't find the error. I want to get the screen size with a separate class (called Screen) and want it to be accessed as a static variable...
Ood
0

votes
2

answer
34

Views

Why and When there is need to re-declare static method in derived class if its definition cannot overridden/altered by derived class?

I am familiar with static keyword, and how it used. I understand that a static method can be re-declared in sub-class but its definition gets hidden and remains same as of parent class. I am mentioning some links of articles I've already read: https://www.geeksforgeeks.org/can-we-overload-or-overrid...
Emmy
0

votes
1

answer
1.3k

Views

How do I add back elements with GWT after removing them with DOM.removeChild()?

I am using GWT 2.5 for an application. I have some static HTML with a specially named div, and I am using HTMLPanel.wrap() to replace that div with a GWT login panel. Once the user logs in I am using DOM.removeChild() to remove all the static elements from the page and use nothing but GWT widgets. T...
James B
1

votes
1

answer
889

Views

Properly Linking a static library with the C math library

I have a library which uses the log function from math.h. When I compile and package this library, I get no compilation errors, which is normal (I think). Now when I try to use the library in an application, gcc gives me linker errors: Compiling mytestlist using 'mytestlist.o': gcc mytestlist.o -I/s...
smac89
4

votes
3

answer
120

Views

Java bad practice doing: new… ().doSomething()?

I just saw a piece of code that had some classes with only one method. I picked an examples: public class TempDirCleanupProcess { public void cleanup(final File directory) {} } Then, later on in the code the method was called the following way: new TempDirCleanupProcess().cleanup(tempDir); Now I am...
ItFreak
1

votes
2

answer
290

Views

GitLab CI: How to fail on new compiler warnings

We are trying to get an old legacy code base under control while simultaneously developing new features. Currently the code compiles with a hell of a lot of compiler warnings and warnings from static code analyzers. For that reason it is not uncommon that code introducing new warnings reaches produc...
sigy
1

votes
1

answer
42

Views

Delay initialisation of static variables in a 3rd party library

I'm linking against a 3rd party library that uses static variables. These end up getting initialised before main and grab resources prematurely, causing some havoc in my application. Is there any idiom / technique/ wrapping method, to regain control and define the point in execution where the librar...
learnvst
1

votes
1

answer
63

Views

Not able to set cache-control header for my static resources Express

I am using Express in the backend and React(create-react-app) in the frontend. React produces all my bundled assets in client/build/static directory The directory has three folders in it css, js, media. I see that they have a max-age=0 in the network tab of the developer console. So, I try to use e...
Aakash
1

votes
2

answer
86

Views

Can I avoid recompiling my platform layer without `static mut`? [duplicate]

This question already has an answer here: How do I create a global, mutable singleton? 1 answer How can you make a safe static singleton in Rust? 2 answers I have a library 'business logic' crate I want to be able to write multiple binary crate 'frontends' or 'platform layers' for. These platform...
Ryan1729
1

votes
2

answer
40

Views

Why do I get compile time error when base class pointer points to derived class virtual function that is declared in base class?

I have a base class which has virtual void function1( ) and that is overridden in derived class. Additionally there is one more virtual function in my derived class as below. class Base { public: virtual void function1() { cout
arjun jawalkar
1

votes
1

answer
101

Views

C and static Code analysis: Is this safer than memcpy?

Is the following function safer than using memcpy? Memcpy gives the following 'Improper_Null_Termination' Error in Checkmarx static code analysis: The string in at line is stripped of its terminating null-byte by at . However, if I use the following function, Checkmarx has no issue: void myMem...
1

votes
2

answer
97

Views

How can I macro #define a static method call in C++?

I am trying to write software that can behave differently based on whether or not a certain component should be simulated in software or execute on real hardware. However, GCC complains that the Scope resolution operator (::) cannot be used in a macro, so my question is: is it possible to define a m...
xyzhou
1

votes
2

answer
46

Views

creating a static library using g++ -std=c++11 using templates

While creating a static library using c++11, it fails during linking I think. I can create a static library and link to it using the information in How to create a static library with g++? with ordinary c++, but if I try to follow the steps using c++11 features, it fails during the linking. test.cpp...
Third
1

votes
3

answer
28

Views

Making static_assert block re-usable

Say I have a template class that makes multiple static_asserts: template class Foo { static_assert(!std::is_const::value,''); static_assert(!std::is_reference::value,''); static_assert(!std::is_pointer::value,''); //...... Now say I have more template classes that need to make the same asserts. Is...
Unimportant
1

votes
5

answer
2.3k

Views

Hiding C++ symbols in iOS static library?

I've made an iOS code library in pure C++, which I intend to publish to a lot of people. As far as I know, at the time of writing, the only way to share compiled code on iOS is through a static library. Unfortunately, there are some clever bits in the code which I'd like to hide from public view. Wh...
Simplex
1

votes
4

answer
1.6k

Views

C++ Compile-time polymorphism

There two unrelated structures A and B template struct A {}; template struct B {}; one enum type typedef enum { ma, mb} M; and class C containing function templates class C { public: template static void f1 ( A &a) {} template static void f2 ( B &b) {} template static void algo (U &u, M m)...
justik
1

votes
2

answer
7.3k

Views

how to point to static folder in django

I am learning django and I already have a bit noobish question. I can not point to my static folder and I tried all the combinations, watched people do it in youtube tutorials etc. My settings.py looks something like this: STATIC_ROOT = '/home/peter/brewery/static/' TEMPLATE_DIRS = '/home/peter/brew...
user1035617
0

votes
0

answer
19

Views

Override static getter in ES6

Assume I have an ES6 mixin like this: // InputMixin.js export const InputMixin = (base) => { return class Base extends base { static get _attribs() { return ['autofocus', 'autocomplete', 'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'name', 'type', 'value'] } sta...
Merc
0

votes
0

answer
11

Views

How to add a custom font to a static website in Heroku?

I created a static page website using just html and css and deployed it to Heroku and want to use a custom font I downloaded online. It works in my local repository, but I do not know how to use the font through heroku. Currently I tried adding the font in my folder, but that does not help. * { /*...
Ji One Yang
1

votes
1

answer
65

Views

How can I have a listing page for categorized content in Hugo?

I want to categorize some events like meetups and conferences. I want to have a page on /events where I can see all events and /events/meetups where I can see all meetups. My problem is that if I organize my pages in a section named events and I put my markdown files in the two folders meetups and c...
Adam Arold
1

votes
0

answer
158

Views

Django 1.11 static files not loading

Setting.py STATIC_URL = '/static/' PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = os.path.join(PROJECT_DIR,'static') TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),) There are static files in my directory, I have tried every possible solution.
Gaurav Bhagat
1

votes
0

answer
57

Views

How to check via static code analysis if java.nio.file is used

I am working on a Java library that is can be used both as a generic Java library and as an Android library. I want to avoid using java.nio.file.* classes because they were introduced in the Android platform just recently with API 26, while my Android library targets API 21 and later. How can I ensu...
Kaloyan Raev
1

votes
0

answer
91

Views

Python3 Sine Function to fit Data

I have data which I broke into 28day slices. Here is a plot of the means of each of these slices. I have to calculate some values from equation that fits the data reasonably well, and then find the correlation coefficient between those values and the means for each 28-day slice. Since I have one mea...
Nick
1

votes
0

answer
468

Views

How to clear static variables globally in Swift?

There a logout feature for my application where I intend to clear all static variables that were created throughout the life of the login session. How can these static variables be cleared globally? Currently I'm setting all static variable individually to nil ex: staticVariableSessionID = nil
as diu
1

votes
2

answer
58

Views

How to fetch sms using static method

SmsAdapter.java package com.s4starb4boy.smstopdf.adapter; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import co...
s4starb4boy
1

votes
0

answer
57

Views

Why is it possible to call static class methods by replicating the class name prefix multiple times? [duplicate]

This question already has an answer here: Calling a static method by repeating the object name? 3 answers Why is there an injected class name? 1 answer class E { public: static void f() {}; }; int main() { E::f(); E::E::f(); E::E::E::E::f(); } why is it possible to do this ? It does not work with...
Silviu
1

votes
1

answer
39

Views

New instance of inner static class has variables in different order in pre-lollipop devices

I am working on a bug in existing code-base of an android application. We have a static inner class like shown below: public class MyOuterClass{ private MyInnerClass myInnerClassObject; private int someOtherVariable; // getter and setter of my inner class public MyInnerClass getMyInnerClassObject(){...
Dhiraj Sharma
1

votes
1

answer
311

Views

QMAKE: Link static library against another static library

I have a QMAKE staticlib project (libtest.a) that deppends to ther subproject (liblogger.a) I try to add his to test.pro: LIBS += -L$$OUT_PWD/../libs/logger/ -llogger PRE_TARGETDEPS += $$OUT_PWD/../libs/logger/liblogger.a but, finaly, qmake pack .a library without liblogger.a ar cqs libtest.a libtes...
M.A. Pons
1

votes
0

answer
62

Views

Static and dynamic bindning

I have tried to find information on the internet but I have not got a clear picture of it. My question is what affect static and dynamic binding have on encapsulation, inheritance, subtype polymorphism in object orientated programming?
thpthp
1

votes
1

answer
74

Views

Shared Object is statically linked against boost program_options; application links shared

I'm working on a library that is statically linking our boost dependencies so that we do not have to worry about conflicting with users. Our library statically links date_time system thread regex filesystem program options We then have an executable that also needs program_options and links against...
Mike K.
1

votes
0

answer
71

Views

Nifty counter in precompiled header does not work

To fix a problem caused by the static (de-)initialization order fiasco I tried to use the Nifty Counter idiom aka Schwartz Counter. I noticed, however, that it does not work if the header file containing the static initializer is included inside Visual Studio's precompiled header. In such a case I s...
sigy
1

votes
1

answer
398

Views

Mongocxx static driver example fails

I followed the instruction at to build static library http://mongoc.org/libmongoc/current/installing.html for MongoDB C Driver (version 1.9.2). It installed correctly and can build examples as gcc -o hello_mongoc hello_mongoc.c $(pkg-config --libs --cflags libmongoc-static-1.0) Next I wanted a mong...
Roshan Mehta
1

votes
0

answer
67

Views

Static code analysis for SenseTalk

I am looking for a static code analysis tool for SenseTalk which can be extended to perform my custom rules. I need to identify dead codes and verify the naming conventions of variables and functions(Bonus: identify duplicate codes).I was not able to find a readily available tool to perform SCA on S...
333

View additional questions