Re: [Dev-C++] Split code in public/private parts - Help please
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jean-Marc G. <go...@sk...> - 2004-01-11 11:07:18
|
Thanks a lot for your very adequate answer, Ferdinando.
I have two extra questions, based on your answer ... Sorry it is a little
off-topic now since it is more like a general C question.
(1) What is the difference between a ".o" file and a ".lib" file (library)
and how can I convert one in the other ?
(2) I understand it is not possible to prevent someone from calling all of
the functions in the ".o" file. Yet, I just noticed the names of all my
variables and functions appear "in clear" in the code of the ".o" file (when
opening it with a text processor). Is there a way to avoid this (as the
names are explicit and give hints about the way the program works) ? Of
course, I can just give names as "a", "b", "c"... but then I get lost in my
source code. I tried to use "static" but it does not change a thing ...
Any help is welcome !
Thanks again,
Jean-Marc
----- Original Message -----
From: "Ferdinando Formica" <s2...@st...>
To: <go...@sk...>
Cc: "Dev-C++ Mailing List" <dev...@li...>
Sent: Saturday, January 10, 2004 7:51 PM
Subject: Re: [Dev-C++] Split code in public/private parts - Help please
>
> > How can I compile "part two" (which has no "main" function),
> > so that the source code cannot be seen anymore ?
>
> You can put "part two" in a separate file, and compile it singularly, then
> distribute the output file (with .o extension).
>
> > Then, how can I compile "part one" source code (which has
> > the "main" function) with "part two" compiled version?
>
> You have to include in your project the .o file selecting "include in
> link" and deselecting "include in compilation", or equivalently build a
> library from it (a .a file), call it e.g. libp2.a, and specify "-lp2" in
> linker options.
>
> > How can I make sure it is not possible
> > to call directly another function of "part two" ?
>
> _Really_ you can't, but only who knows the implementation (or is a good
> and patient reverse engineer) know what's inside an object file. You
> should put declarations for all functions you would like a programmer to
> call in a header (.h) and distribute it with your .o or .a file.
>
> Bye, Ferdinando.
>
>
>
|