Thread overview |
---|
March 08, 2003 Import or Not | ||||
---|---|---|---|---|
| ||||
I'm creating a library that I want to compile separately and make into a .lib file. I want to use that library in other programs obviously. How do the programs using the .lib "see" the class definitions in the library? Do I have to provide some sort of symbol file containing the definitions using the "import" statement? If so, how do I show the definitions without divulging all the code? What would such a definition file look like? How does the Phobos library work in that regard? We don't have to import any definitions from Phobos. Why? Thanks... Gary. |
March 09, 2003 Re: Import or Not | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary | "Gary" <gedumer@bcpl.net> wrote in message news:b4ctkg$c5v$1@digitaldaemon.com... > I'm creating a library that I want to compile separately and make into a .lib file. I want to use that library in other programs obviously. How do the programs using the .lib "see" the class definitions in the library? Do I > have to provide some sort of symbol file containing the definitions using the "import" statement? If so, how do I show the definitions without divulging all the code? What would such a definition file look like? How does the Phobos library work in that regard? We don't have to import any definitions from Phobos. Why? Take a look at phobos/gc.d and phobos/gc2/gd.d. That's an example of what you're trying to accomplish. |
March 09, 2003 Re: Import or Not | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | I don't think that's quite what I'm looking for. Let me show you a very simple example that illustrates my question exactly. The following is a sample library. It's compiled using "DMD -c x.d". class a { protected: int b; this(int z){b = z;} public: void set(int z){b = z;} int get(){return b;} } An OBJ file is created. The following program is created by a user. It uses the above library. It's compiled using "DMD y.d x.obj". import x; int main(char[][] args) { a a1 = new a(25); a1.set(150); printf("b=%d",a1.get()); return 0; } It works fine because It has "import x;" at line 1, but if I remove the "import" statement, it fails because it can't see "class a". But I don't want the user to see the code in the library so I'm not going to give them access to it. Here's my question: What should the "import" file look like so the user program can use "class a" without having all the library code? Is there some way to prototype the class without divulging all the internal code? If so, what does it look like... exactly? Thanks... Gary. "Walter" <walter@digitalmars.com> wrote in message news:b4e5n2$vcr$1@digitaldaemon.com... > > "Gary" <gedumer@bcpl.net> wrote in message news:b4ctkg$c5v$1@digitaldaemon.com... > > I'm creating a library that I want to compile separately and make into a .lib file. I want to use that library in other programs obviously. How do > > the programs using the .lib "see" the class definitions in the library? Do > I > > have to provide some sort of symbol file containing the definitions using > > the "import" statement? If so, how do I show the definitions without divulging all the code? What would such a definition file look like? How does the Phobos library work in that regard? We don't have to import any definitions from Phobos. Why? > > Take a look at phobos/gc.d and phobos/gc2/gd.d. That's an example of what you're trying to accomplish. > > |
April 15, 2003 Re: Import or Not | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gary | "Gary" <gedumer@bcpl.net> wrote in message news:b4fk0e$1lug$1@digitaldaemon.com... > I don't think that's quite what I'm looking for. Let me show you a very simple example that illustrates my question exactly. > > The following is a sample library. It's compiled using "DMD -c x.d". > > class a > { > protected: > int b; > this(int z){b = z;} > public: > void set(int z){b = z;} > int get(){return b;} > } > > An OBJ file is created. The following program is created by a user. It uses > the above library. It's compiled using "DMD y.d x.obj". > > import x; > > int main(char[][] args) > { > a a1 = new a(25); > a1.set(150); > printf("b=%d",a1.get()); > return 0; > } > > It works fine because It has "import x;" at line 1, but if I remove the "import" statement, it fails because it can't see "class a". But I don't want the user to see the code in the library so I'm not going to give them access to it. > > Here's my question: What should the "import" file look like so the user program can use "class a" without having all the library code? Is there some > way to prototype the class without divulging all the internal code? If so, what does it look like... exactly? Here it is: class a { protected: int b; this(int z); public: void set(int z); int get(); } |
Copyright © 1999-2021 by the D Language Foundation