digitalmars.D.learn - Trouble with modules
- Andrew Madigan (20/20) Apr 14 2006 I have a file called HttpCommon.d where I am throwing code that needs to...
- Derek Parnell (8/14) Apr 15 2006 There is a restriction in D in that one cannot have a module with the sa...
- Andrew Madigan (11/27) Apr 15 2006 hmmm, maybe I am misunderstanding, but the directory these files are in ...
- Derek Parnell (9/40) Apr 15 2006 Sorry, it was my misunderstanding (I rushed a reply as I was going out t...
- John C (3/31) Apr 15 2006 You get this message if you haven't passed a file to the compiler.
- Andrew Madigan (4/38) Apr 15 2006 andymadigan@andym:~/dhttp$ gdc -c Request.d HttpCommon.d
- Chris Nicholson-Sauls (4/9) Apr 15 2006 I have actually done almost this exactly same thing... multiple times. ...
- Andrew Madigan (3/14) Apr 15 2006 Wow, I need to stop making dumb posts to this forum, I must have looked ...
- Andrew Madigan (30/46) Apr 15 2006 Allright, now I'm getting a related error, there are two functions defin...
- Deewiant (3/34) Apr 15 2006 It seems like you're compiling both HttpCommon.d and HttpCommon.o, and t...
I have a file called HttpCommon.d where I am throwing code that needs to be imported by a few files in my project. It contains an enum and a few constants. When I try to to import it, I get the following error: Request.d:5: module HttpCommmon cannot read file 'HttpCommmon.d' HttpCommon.d (in the same directory) contains: //Common globals for HTTP enum Protocol { //Removed } static char[] getProtocolName(Protocol protocol) { //Removed } static Protocol getProtocolByName(char[] name) { //Removed } class StatusCode { //Removed } What's going on? I don't understand how the compiler finds files, but I'm thinking that's where it's going wrong.
Apr 14 2006
On Sat, 15 Apr 2006 16:19:36 +1000, Andrew Madigan <amadigan gmail.com> wrote:I have a file called HttpCommon.d where I am throwing code that needs to be imported by a few files in my project. It contains an enum and a few constants. When I try to to import it, I get the following error: Request.d:5: module HttpCommmon cannot read file 'HttpCommmon.d' HttpCommon.d (in the same directory) contains:There is a restriction in D in that one cannot have a module with the same name as the directory it appears in. The simple workaround is to rename one or the other. -- Derek Parnell Melbourne, Australia
Apr 15 2006
Derek Parnell wrote:On Sat, 15 Apr 2006 16:19:36 +1000, Andrew Madigan <amadigan gmail.com> wrote:hmmm, maybe I am misunderstanding, but the directory these files are in is called "dhttp" (I'm on linux, so the path is really just ~/dhttp). The file structure looks like this: dhttp Request.d HttpCommon.d [other d files] Makefile Does HttpCommon need to be in a subdirectory? I admit I find all this a little confusing, Java handles things a little differently.I have a file called HttpCommon.d where I am throwing code that needs to be imported by a few files in my project. It contains an enum and a few constants. When I try to to import it, I get the following error: Request.d:5: module HttpCommmon cannot read file 'HttpCommmon.d' HttpCommon.d (in the same directory) contains:There is a restriction in D in that one cannot have a module with the same name as the directory it appears in. The simple workaround is to rename one or the other.
Apr 15 2006
On Sat, 15 Apr 2006 18:27:44 +1000, Andrew Madigan <amadigan gmail.com> wrote:Derek Parnell wrote:Sorry, it was my misunderstanding (I rushed a reply as I was going out to see my football team play - they lost). Have you tried the Build utility? It would avoid spelling mistakes like this. -- Derek Parnell Melbourne, AustraliaOn Sat, 15 Apr 2006 16:19:36 +1000, Andrew Madigan <amadigan gmail.com> wrote:hmmm, maybe I am misunderstanding, but the directory these files are in is called "dhttp" (I'm on linux, so the path is really just ~/dhttp). The file structure looks like this: dhttp Request.d HttpCommon.d [other d files] Makefile Does HttpCommon need to be in a subdirectory? I admit I find all this a little confusing, Java handles things a little differently.I have a file called HttpCommon.d where I am throwing code that needs to be imported by a few files in my project. It contains an enum and a few constants. When I try to to import it, I get the following error: Request.d:5: module HttpCommmon cannot read file 'HttpCommmon.d' HttpCommon.d (in the same directory) contains:There is a restriction in D in that one cannot have a module with the same name as the directory it appears in. The simple workaround is to rename one or the other.
Apr 15 2006
Andrew Madigan wrote:I have a file called HttpCommon.d where I am throwing code that needs to be imported by a few files in my project. It contains an enum and a few constants. When I try to to import it, I get the following error: Request.d:5: module HttpCommmon cannot read file 'HttpCommmon.d'You get this message if you haven't passed a file to the compiler. dmd HttpCommon.dHttpCommon.d (in the same directory) contains: //Common globals for HTTP enum Protocol { //Removed } static char[] getProtocolName(Protocol protocol) { //Removed } static Protocol getProtocolByName(char[] name) { //Removed } class StatusCode { //Removed } What's going on? I don't understand how the compiler finds files, but I'm thinking that's where it's going wrong.
Apr 15 2006
John C wrote:Andrew Madigan wrote:andymadigan andym:~/dhttp$ gdc -c Request.d HttpCommon.d Request.d:5: module HttpCommmon cannot read file 'HttpCommmon.d' Note that HttpCommon.d does build fine.I have a file called HttpCommon.d where I am throwing code that needs to be imported by a few files in my project. It contains an enum and a few constants. When I try to to import it, I get the following error: Request.d:5: module HttpCommmon cannot read file 'HttpCommmon.d'You get this message if you haven't passed a file to the compiler. dmd HttpCommon.dHttpCommon.d (in the same directory) contains: //Common globals for HTTP enum Protocol { //Removed } static char[] getProtocolName(Protocol protocol) { //Removed } static Protocol getProtocolByName(char[] name) { //Removed } class StatusCode { //Removed } What's going on? I don't understand how the compiler finds files, but I'm thinking that's where it's going wrong.
Apr 15 2006
Andrew Madigan wrote:andymadigan andym:~/dhttp$ gdc -c Request.d HttpCommon.d Request.d:5: module HttpCommmon cannot read file 'HttpCommmon.d' Note that HttpCommon.d does build fine.I have actually done almost this exactly same thing... multiple times. You have three 'm's in HttpCommmon in Request.d line 5. -- Chris Nicholson-Sauls
Apr 15 2006
Chris Nicholson-Sauls wrote:Andrew Madigan wrote:Wow, I need to stop making dumb posts to this forum, I must have looked at that same line of code 50 times.andymadigan andym:~/dhttp$ gdc -c Request.d HttpCommon.d Request.d:5: module HttpCommmon cannot read file 'HttpCommmon.d' Note that HttpCommon.d does build fine.I have actually done almost this exactly same thing... multiple times. You have three 'm's in HttpCommmon in Request.d line 5. -- Chris Nicholson-Sauls
Apr 15 2006
Andrew Madigan wrote:Chris Nicholson-Sauls wrote:Allright, now I'm getting a related error, there are two functions defined in HttpCommon.d (they're global). I'm getting errors about multiple definition. What should I do? gdc HttpCommon.d -o http Application.o HttpCommon.o http.o InterruptableThread.o Request.o RequestThread.o RootApplication .o StatusCode.o TestApp.o WebServer.o HttpCommon.o: In function `_D10HttpCommon10HttpCommon15getProtocolNameFE10HttpCommon8ProtocolZAa ':HttpCommon.d:(.text+0x0): multiple definition of `_D10HttpCommon10HttpCommon15getProtocolNameFE10HttpCommon8ProtocolZAa' /tmp/cccBIwTr.o:HttpCommon.d:(.text+0x0): first defined here HttpCommon.o: In function `_D10HttpCommon10HttpCommon17getProtocolByNameFAaZE10HttpCommon8Protocol ':HttpCommon.d:(.text+0x5 e): multiple definition of `_D10HttpCommon10HttpCommon17getProtocolByNameFAaZE10HttpCommon8Protocol' /tmp/cccBIwTr.o:HttpCommon.d:(.text+0x5e): first defined here HttpCommon.o:(.rodata+0x14): multiple definition of `_init_10HttpCommon10HttpCommon' /tmp/cccBIwTr.o:(.rodata+0x14): first defined here HttpCommon.o:(.rodata+0x28): multiple definition of `_vtbl_10HttpCommon10HttpCommon' /tmp/cccBIwTr.o:(.rodata+0x28): first defined here HttpCommon.o:(.data+0x0): multiple definition of `_Class_10HttpCommon10HttpCommon' /tmp/cccBIwTr.o:(.data+0x0): first defined here collect2: ld returned 1 exit status make: *** [http] Error 1Andrew Madigan wrote:Wow, I need to stop making dumb posts to this forum, I must have looked at that same line of code 50 times.andymadigan andym:~/dhttp$ gdc -c Request.d HttpCommon.d Request.d:5: module HttpCommmon cannot read file 'HttpCommmon.d' Note that HttpCommon.d does build fine.I have actually done almost this exactly same thing... multiple times. You have three 'm's in HttpCommmon in Request.d line 5. -- Chris Nicholson-Sauls
Apr 15 2006
Andrew Madigan wrote:Allright, now I'm getting a related error, there are two functions defined in HttpCommon.d (they're global). I'm getting errors about multiple definition. What should I do? gdc HttpCommon.d -o http Application.o HttpCommon.o http.o InterruptableThread.o Request.o RequestThread.o RootApplication .o StatusCode.o TestApp.o WebServer.o HttpCommon.o: In function `_D10HttpCommon10HttpCommon15getProtocolNameFE10HttpCommon8ProtocolZAa ':HttpCommon.d:(.text+0x0): multiple definition of `_D10HttpCommon10HttpCommon15getProtocolNameFE10HttpCommon8ProtocolZAa' /tmp/cccBIwTr.o:HttpCommon.d:(.text+0x0): first defined here HttpCommon.o: In function `_D10HttpCommon10HttpCommon17getProtocolByNameFAaZE10HttpCommon8Protocol ':HttpCommon.d:(.text+0x5 e): multiple definition of `_D10HttpCommon10HttpCommon17getProtocolByNameFAaZE10HttpCommon8Protocol' /tmp/cccBIwTr.o:HttpCommon.d:(.text+0x5e): first defined here HttpCommon.o:(.rodata+0x14): multiple definition of `_init_10HttpCommon10HttpCommon' /tmp/cccBIwTr.o:(.rodata+0x14): first defined here HttpCommon.o:(.rodata+0x28): multiple definition of `_vtbl_10HttpCommon10HttpCommon' /tmp/cccBIwTr.o:(.rodata+0x28): first defined here HttpCommon.o:(.data+0x0): multiple definition of `_Class_10HttpCommon10HttpCommon' /tmp/cccBIwTr.o:(.data+0x0): first defined here collect2: ld returned 1 exit status make: *** [http] Error 1It seems like you're compiling both HttpCommon.d and HttpCommon.o, and that they're conflicting with each other.
Apr 15 2006