"Error: function expected before (), not module *module* of type void

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 24 10:41:11 PDT 2008


"Dustin Mays" wrote
> I'm getting the following error message when trying to compile a test-app 
> I wrote:
> diceroller.d(9): Error: function expected before (), not module rollDice 
> of type void

I know you fixed the problem, but just an FYI, the reason is because when 
you import rollDice, you bring both rollDice the module and rollDice the 
function into the global namespace (which confuses the compiler 'cause it 
doesn't know what symbol you want to use).  This is normally avoided in 
libraries by having a package tree.  So for example, if you created 
everything in the subdirectory foo, and had your modules be:

module foo.diceroller;
import foo.rollDice;

Then the import would import the module foo.rollDice, and the function 
rollDice, and the compiler would no longer be confused about what you are 
trying to call.

IMO, this makes it difficult to write multi-file applications that live in 
one directory.  It would be nice if this was changed...

-Steve 




More information about the Digitalmars-d-learn mailing list