Thread: Compiling error expected expression.

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    6

    Compiling error expected expression.

    Hi all,
    As you guessed a newbie but oldie

    I'm writing a gtk tray app that shows pop3 mailbox mail count number in the tooltip.

    I'm using library libspopc

    I have followed the one page manual instructions for calling the functions available.

    I admit I just don't know what this means ' popsession* mysession ' and it's further use ' popsession** &mysession ' in the following code snippet.(The whole thing is a bit large to post) it errors at compile with 'expected expression before popsession' , incidently so does the example code supplied with the library.

    Code:
            char pmailis[15];
    	popsession* mysession;
    	char* err=NULL;
    	
    	libspopc_init();
    
    	err = popbegin(servertoo, usertoo, pass, popsession** &mysession);
    
    	if(err){
    		printf("%s",err);
    		free(err);
    		exit(1);
    	         }
    	g_print ("Connected ?");
    Last edited by tasmod; 08-12-2010 at 03:15 PM.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    This seems suspect
    err = popbegin(servertoo, usertoo, pass, popsession** &mysession);
    Perhaps it should be
    err = popbegin(servertoo, usertoo, pass, &mysession);
    ?

    If you don't know what
    popsession* mysession;
    means, then you will have to read up on pointers. Very basic C concept but oh so important.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Code:
    popsession* mysession;
    Somewhere, the popsession type should have been defined (look for something to the effect of "typedef ______ popsession" - as that error seems to me to be indicating that the compiler actually hasn't seen that type get defined). It's probably a struct. This line is declaring a pointer to a popsession. If you don't know what pointers or structs are - you probably want to find a tutorial that covers them - it would surely be better than a quick explanation from me. I'm afraid I can't be more specific, as I'm not familiar with the library.

    err = popbegin(servertoo, usertoo, pass, popsession** &mysession);
    If a 'newbie' came up with that on their own I'd immediately write it off as a mistake, but since you found this in documentation, I'm a tad hesitant to be so quick to judge. You don't put the type of the arguments in when you're calling a function - only when you're declaring / defining it. The & operator gets the address of something. popsesssion** means it's a pointer to a pointer (or address of a pointer), and since mysession is a pointer, what they probably meant was this:

    Code:
    err = popbegin(servertoo, usertoo, pass, &mysession);

  4. #4
    Registered User
    Join Date
    Aug 2010
    Posts
    6
    Thanks guys,

    I just didn't recognise it as a pointer.

    Hmm, something wrong in the compile line I'm sure.

    Changing the line to the suggested brings up undefined errors pointing back to a
    Code:
     typedef struct { blah blah blah}popsession;
    in the header file. I suspect it isn't finding the header file etc.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Can you post the exact error message and the code it points to?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Aug 2010
    Posts
    6
    This is an extract from the one page text "manual"


    === declarations ===
    To use libspopc, you have to include in your main program the libspopc header:

    Code:
    	#include <libspopc.h>
    Then, in you main function, declare a popsession* object. You don't need to
    know what a popsession consists of, but if you are curious, see libspopc.h.

    Code:
    	popsession* mysession;

    === starting the pop session ===

    Since version 0.9, you must call libspopc_init() before starting to use libspopc routines.

    Code:
    	libspopc_init(); /* version >= 0.9 */
    Now, to start a pop3 dialog with a pop3 server, use:

    Code:
    	error = popbegin(char* servername, char* user, char* pass, popsession** &mysession);
    If no error occurs, popbegin returns a NULL pointer. Else, it returns an error
    message and the session is not initialized. When the session is initialized,
    popbegin will asks the pop3 server to give him knowledge of how many messages
    are stored, and how many bytes, etc... You can know them by reading the popsession
    members with provided macros (see <libspopc.h>).


    Sorry, should have been just text but forum nagged me to use code tags.

  7. #7
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Have you looked at poptest2.c in the examples?

  8. #8
    Registered User
    Join Date
    Aug 2010
    Posts
    6
    Compile error message once line in code has been changed:-

    In function popmail

    /tmp/ccfc04x4.o
    undefined reference to `libspoc_init`
    undefined reference to `popbegin`
    undefined reference to `popcancel`
    undefined reference to `popend`
    undefined reference to `libspopc_clean`

    These are all in the header and i make calls from the function.

    I've missed out the begining hex references to each line.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You're not linking against the correct .lib file. Consult the documentation to see what you need to link against.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User
    Join Date
    Aug 2010
    Posts
    6
    poptest2.c was where i originally looked at the line, I then compared it with the manual line. As poptest2.c would not compile with lots of error messages I gave up on that one and concentrated on my own code using the suggested line from the manual.

    It's somewhat embarrasing as I just can't get my head around this. I've just completed two 6-800 line gtk tray icon apps without problems. I guess I'm code dizzy.

  11. #11
    Registered User
    Join Date
    Aug 2010
    Posts
    6
    Grrr, this has all been so futile.

    It appears that the Make Install, didn't. I went looking for the lib and it isn't there, I just assumed it was.

    Sorry guys for the wild goose chase.

    Many thanks for all your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with making a Math Expression DLL
    By MindWorX in forum C Programming
    Replies: 19
    Last Post: 07-19-2007, 11:37 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. recursion error
    By cchallenged in forum C Programming
    Replies: 2
    Last Post: 12-18-2006, 09:15 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. Expression Evaluator Contest
    By Stack Overflow in forum Contests Board
    Replies: 20
    Last Post: 03-29-2005, 10:34 AM