static

Undefined reference to external variable

Having problems with a custom logging system I've made. I am declaring an ofstream within my main file so that it is accessible by static functions within my class. This works for my static function (ilra_log_enabled). However, this does not work on my overloaded function for the class. I receive a undefined reference to "logfile" error....

Shared global variable in C++ static library

I have a MS C++ project (let's call it project A) that I am currently compiling as a static library (.lib). It defines a global variable foo. I have two other projects which compile separately (call them B and C, respectively) and each links the shared static library A in. Both B and C are dll's that end up loaded in the same process. I ...

Partially initialize variable defined in other module.

I'm considering a certain solution where I would like to initialize a cell of an array that is defined in other module (there will be many modules initializing one table). The array won't be read before running main (so there is not problem with static initialization order). My approach: /* secondary module */ extern int i[10]; // th...

C++/CLI, static constructor outside class declaration

Hello, How do I put body of static constructor of a managed class outside class declaration? This syntax seems to be compilable, but does it really mean static constructor, or just a static (=not visible outside translation unit) function? ref class Foo { static Foo(); } static Foo::Foo() {} ...

unset variable in php

hi all of you, I just read about unset variable through php manual. The php manual says "unset() destroys the specified variables" This def seems perfect until I came across static variable... "If a static variable is unset() inside of a function, unset() destroys the variable only in the context of the rest of a function. Follow...

Injecting a static EJB, nonsense ?

Hello everyone, I want to write this piece of code : @Stateless public class MyEjb { @EJB private static MyOtherEjbWhichIWantStatic myOtherEjb; } It makes sense to me, that I want to inject an EJB in my class, as a static element, for various reason. Java is not very happy with that unfortunately com.sun.enterprise.contain...

Is static code always executed when we use a class for the first time?

Our application is using initialization code that depends on the order static code is executed and I'm wondering if this order will be consistent across all JVMs. Here is a sample of what I mean: public class Main { static String staticVar = "init_value"; public static void main(String[] args) { System.out.println(A...

How to resolve "static method ___ should be accessed in a static way" warnings

I'm going through the book Just Java 2 but am evidently missing something basic. These are two separate projects. I've generated a JAR for the second and added it to the first's build path. The correct areas are printed but the compiler generates these warnings. How would these be resolved? // -------------------------------------------...

How is the static function/variable protected

I want to know how a static variable or function is protected to be used only for the file it is defined in. I know that such variables and functions are declared in data section (heap area to be precise), but is it tagged with the file name ? Suppose I make a fool of the compiler by assigning such a static function (defined in foo.c) to...

Static method calls to derived types over virtual implementations? (Android)

I have class A, with methods foo and bar, that are implemented by A1 and A2. The functionality in both A1 and A2 is the same. In other words: public class A { public int foo() { return 0; }; public int bar() { return 1; }; } class A1 extends A { public int AnotherFooFunction() { return foo(); } ...

Android-ndk: difference between static and shared library

Hi I'm new to Android ndk and i didn't understand yet which are the differences between static and shared library. Could you explain me what these differences are? When developing a library how could i choose one of them? Thanks a lot ...

Static const initialization iPhone/Release

I have a cross platform library that has strange problem only on iPhone and only under release. // .h class cColor { public: static const cColor Red; static const cColor Green; static const cColor Blue; u8 r; u8 g; u8 b; u8 a; inline cColor(...) : ... { } }; // .cpp const cColor cColor::Red(0xFF, 0x00, 0x00);...

Make a button rightBarButtonItem STATIC in iPhone

Hi, I want to make a rightBarButtonItem on NavigationBar static, such that on every navigation bar that single instance of button appears. Right now, I am initializing the button for each and every viewController. I want that it should be a single instance should call a single method, from whichever view is gets tapped. And If I change t...

Static member initialization in a template class

I'd like to do this: template <typename T> struct S { ... static double something_relevant = 1.5; }; but I can't since something_relevant is not of integral type. It doesn't depend on T, but existing code depends on it being a static member of S. Since S is template, I cannot put the definition inside a compiled file. How do ...

Problem with Order of "Registration" of .NET Classes in a Messaging Scenario

I've seen this problem come up a lot, but never adequately handled, and I haven't seen it on Stack Overflow, so here goes. I wish there were a way to put this shortly and succinctly without lacking clarity, but I can't seem to shorten it, so bear with me... A good case-study (my current case, of course) to illustrate the problem follow...

Objective-C: Assigning the value of a static variable to an instance variable

I essentially want to give each instance of a class a unique id. So, I created a static integer. I increment it each time a new object is created and then assign the value of the static variable to an ivar. But clearly I don't understand something because, let's say I create three objects, "thisPageNumber" (which is the instance variabl...

PHP Static code Analysis - Finding Class Dependancies

Hi, I am about to start a large refactoring job on a big PHP project. I have successfully used pdepend to generate dependancy reports on the packages outlined in the PHPDoc blocks at the start of every file. The information is really usefull, it outlines dependancies between packages (which packages are used by which, cyclic dependanc...

static linking log4c-1.2.1 with Fedora 12 and Eclipse 3.5.1

Hello All, We are building a project that requires log4c to be linked in the static mode, the following is part of the linker error that is being generated. /usr/local/lib/liblog4c.a(domnode-expat.o): In function `sd_domnode_read': /log4c-1.2.1/src/sd/domnode-expat.c:316: undefined reference to `XML_ParserCreate' /log4c-1.2.1/src/sd/do...

Django Apache static files

I have a couple of conceptual questions: regarding serving static files (media) in Django in production. I understand that Django serves static files in development different than in production: read this: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serving-media-files http://docs.djangoproject.com/en/dev/howt...

How to create a const NSDate

I am trying to define the equivalent of DateTime.MaxValue (C#) but in Objective C. I don't want to keep creating NSDates every time I use it so I wish I had it as const. The problem, the compiler returns "Initializer element is not constant" Here is the code static NSDate* DateTimeMinValue = [NSDateFormatter dateFromString:@"00:00:0...