Skip to content

Instantly share code, notes, and snippets.

@iwadon
Created October 30, 2012 06:27
Show Gist options
  • Select an option

  • Save iwadon/3978621 to your computer and use it in GitHub Desktop.

Select an option

Save iwadon/3978621 to your computer and use it in GitHub Desktop.
gist:3978621 の問題を単純化してみた。まあ仕方ないのかなあ。
#include <iostream>
void set_value(int new_value);
struct Foo
{
Foo()
{
set_value(1);
}
};
Foo foo;
#include <iostream>
int value;
void set_value(int new_value)
{
value = new_value;
}
int main()
{
std::cout << value << std::endl;
return 0;
}
CXX = g++
CXXFLAGS = -Wall -O0 -g
CPPFLAGS =
AR = ar
LD = g++
LDFLAGS =
LIBS =
RM = rm -f
all: ok ng
clean:
$(RM) ok ng
$(RM) libfoo.a
$(RM) main.o foo.o
ok: main.o foo.o
$(LD) $(LDFLAGS) -o $@ main.o foo.o
ng: main.o libfoo.a
$(LD) $(LDFLAGS) -o $@ main.o -L. -lfoo
main.o: main.cc
$(CXX) $(CXXFLAGS) -o $@ -c $<
foo.o: foo.cc
$(CXX) $(CXXFLAGS) -o $@ -c $<
libfoo.a: foo.o
$(RM) $@; $(AR) crs $@ foo.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment