tags:

views:

52

answers:

3

hello, I have some problems with Eclipse, I have structure

struct Account{
    const char* strLastName;      //Client's last name
    const char* strFirstName;     //Client's first name
    int nID;                //Client's ID number
    int nLines;             //Number of lines related to account
    double lastBill;        //Client's last bill for all lines
    List linesDataBase;
};

And I can't compile my code eclipse gives me an errors:

  1. Syntax error before List
  2. no semicolon at end of struct or union
  3. ISO does not allow extra ";" outside a function

I have no idea how to change it, thanks in advance for any help

+1  A: 
  1. You need to show the definition of the type List, that's not a C built-in type.
  2. This might be a follow-on error because of 1.
  3. This too could just be that the compiler becomes confused.

Also, avoid // comments in C, unless you're sure that you're compiling as C99.

unwind
I use flag -std=c99
lego69
I did #define "list.h"there I have typedef struct List_t *List;
lego69
@lego69 Post the code from List.h in your question. And did you #include it before the code for Account?
anon
+1 I almost asked "what's the deal with `//` comments" but then googled it. I think you should elaborate on that. For other people who has the same question: It turns out `//` style comments were added to C only in `c99`. The default `-std` in gcc is `gnu89` which is "ISO C90 plus GNU extensions (including some C99 features)" - that's why you didn't get any error for `//` comments. Try with `-std=c89` and you'll know.
Amarghosh
how You add this grey background to your words?
lego69
@lego In comments: enclose them in backticks: \`asd\` will show up as `asd`. In posts, you select the code and press `Ctrl-K`
Amarghosh
@lego: I hope you mean #include "list.h", not #define. :)
unwind
thanks a lot!!!!!1
lego69
+3  A: 

Presumably you have not defined List, or #included the header file that does define it. Alternatively, you have defined/included it (possibly as a a macro), and there is something very wrong in the definition. This has nothing to do with Eclipse however - it's how the C language works.

anon
A: 
#ifndef LIST_H_
#define LIST_H_

#include <stdbool.h>
/**
 * Generic List Container
 *
 * Implements a list container type.
 * The list his an internal iterator for external use. For all functions
 * where the state of the iterator after calling that function is not stated,
 * it is undefined. That is you cannot assume anything about it.
 *
 * The following functions are available:
 *
 *   listCreate               - Creates a new empty list
 *   listDestroy              - Deletes an existing list and frees all resources
 *   listCopy                 - Copies an existing list
 *   listFilter               - Creates a copy of an existing list, filtered by
 *                              a boolean predicate
 *   listSize                 - Returns the size of a given list
 *   listFirst                - Sets the internal iterator to the first element
 *                              in the list, and returns it.
 *   listNext                 - Advances the internal iterator to the next
 *                              element and returns it.
 *   listInsertFirst          - Inserts an element in the beginning of the list
 *   listInsertLast           - Inserts an element in the end of the list
 *   listInsertBeforeCurrent  - Inserts an element right before the place of
 *                              internal iterator
 *   listInsertAfterCurrent   - Inserts an element right after the place of the
 *                              internal iterator
 *   listRemoveCurrent        - Removes the element pointed by the internal
 *                              iterator
 *   listFind                 - Attempts to set the internal iterator to the
 *                              next elements in the list that fits the criteria
 *   listSort                 - Sorts the list according to a given criteria
 *
 */

/**
 * Type for defining the list
 */
typedef struct List_t *List;...
lego69
I'm working with ADT
lego69