D
db
Hey group
I'm rewriting a small program called lockdown and need a little help
structuring the code. In the past I didn't use nested namespaces and I
placed all my files in one directory. This time I tried to change this,
but ran into some beginner problems. I have:
namespace lockdown;
namespace lockdown::io;
namespace lockdown::io::in;
namespace lockdown::io:ut;
namespace lockdown::modifiers;
I've made a dir to every namepace, so I have:
io
io/in
io/out
modifiers
btw I'm using FreeBSD and gcc.
The lockdown::io::in namespace is defined in io/in.hpp, but first
mentioned in io.hpp. All the code (classed and functions) for that
namespace is placed in the io/in dir.
Let's look at io.hpp:
#ifndef LOCKDOWN_IO_HPP
#define LOCKDOWN_IO_HPP
#include "lockdown.hpp" //Here lockdown::io is mentioned for the first time
namespace lockdown { namespace io {
//nested namespace where the definition is in the dir
lockdown/io/out.hpp namespace out {}
namespace in {}
class IOException;
//Class definition is in lockdown/io/File.hpp
class File;
}}
Is that the right way of doing it? Or should I #include the definition
of the namespaces and classes/functions?
Next question is about Makefile's. In every dir I have a Makefile that
compiles every file and dir in that dir and makes a "dir".o file and
place it in the above dir. Let's take a look at some Makefile's:
The Makefile in lockdown/io/out
CXX ?= g++
CFLAGS += -Wall
all: Output.o
cp Output.o ../out.o
Output.o: Output.hpp
$(CXX) $(CFLAGS) -c Output.cpp -o $@
clean:
rm -f *.o
In lockdown/io/Makefile I have:
CXX ?= g++
CFLAGS += -Wall
all: out.o File.o
$(CXX) $(CFLAGS) -shared File.o out.o -o ../io.o
out.o:
make -C out all
File.o: File.hpp
$(CXX) $(CFLAGS) -c File.cpp -o $@
clean:
rm -f *.o
make -C out clean
Is that how it is done? The problem here is that I don't want to use
shared objects, but I can't see how to avoid it (don't want to include
very .o file in the entire project then linking the final lockdown
executable).
br
db
Btw: I can send you the code if you wanna see it...just don't download
it from lockdown.trunet.dk as it is an old version.
I'm rewriting a small program called lockdown and need a little help
structuring the code. In the past I didn't use nested namespaces and I
placed all my files in one directory. This time I tried to change this,
but ran into some beginner problems. I have:
namespace lockdown;
namespace lockdown::io;
namespace lockdown::io::in;
namespace lockdown::io:ut;
namespace lockdown::modifiers;
I've made a dir to every namepace, so I have:
io
io/in
io/out
modifiers
btw I'm using FreeBSD and gcc.
The lockdown::io::in namespace is defined in io/in.hpp, but first
mentioned in io.hpp. All the code (classed and functions) for that
namespace is placed in the io/in dir.
Let's look at io.hpp:
#ifndef LOCKDOWN_IO_HPP
#define LOCKDOWN_IO_HPP
#include "lockdown.hpp" //Here lockdown::io is mentioned for the first time
namespace lockdown { namespace io {
//nested namespace where the definition is in the dir
lockdown/io/out.hpp namespace out {}
namespace in {}
class IOException;
//Class definition is in lockdown/io/File.hpp
class File;
}}
Is that the right way of doing it? Or should I #include the definition
of the namespaces and classes/functions?
Next question is about Makefile's. In every dir I have a Makefile that
compiles every file and dir in that dir and makes a "dir".o file and
place it in the above dir. Let's take a look at some Makefile's:
The Makefile in lockdown/io/out
CXX ?= g++
CFLAGS += -Wall
all: Output.o
cp Output.o ../out.o
Output.o: Output.hpp
$(CXX) $(CFLAGS) -c Output.cpp -o $@
clean:
rm -f *.o
In lockdown/io/Makefile I have:
CXX ?= g++
CFLAGS += -Wall
all: out.o File.o
$(CXX) $(CFLAGS) -shared File.o out.o -o ../io.o
out.o:
make -C out all
File.o: File.hpp
$(CXX) $(CFLAGS) -c File.cpp -o $@
clean:
rm -f *.o
make -C out clean
Is that how it is done? The problem here is that I don't want to use
shared objects, but I can't see how to avoid it (don't want to include
very .o file in the entire project then linking the final lockdown
executable).
br
db
Btw: I can send you the code if you wanna see it...just don't download
it from lockdown.trunet.dk as it is an old version.