Thread: Can't compile, don't understand why

  1. #1
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102

    Can't compile, don't understand why

    I couldn't figure this out, so I deleted all other functions from the file, removed all headers, removed a bunch of stuff from the function, and all I have left is a Bookmark.c file with the below code. I tried using the Clean intermediate files thing then recompiling and still same error. I've been getting this error on and off throughout th project and it is causing a big problem. At first it seemed to have something to do with file opening functions but I removed all those. The function looks pointless because I've removed most everything from it.
    PHP Code:
    unsigned long prevIP=0;//a global variable

    void ODBG_Pluginmainloop()
    {

            
    unsigned long testip=5;
            
            if(
    prevIP!=testip)
            {
                
    prevIP=testip;
                
    unsigned long *testippntr=&testip;//the first error refers to this line

            
    }        

        return;


    Compiling...
    BOOKMARK.C
    C:\WINDOWS\Desktop\Copy of odpvc106\BOOKMARK.C(11) : error C2143: syntax error : missing ';' before 'type'
    Error executing cl.exe.

    BOOKMARK.OBJ - 1 error(s), 0 warning(s)

    Using Visual studio 6.0

    Thanks in advance for any replies.
    WebSnozz-
    Cats have no butt cheeks.
    If one farted, then it would make a flute noise.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You must declare variables before anything else in that scope. As such, swap that line with the line above it, and you'll be fine.

    This is C and not C++. In C++ your code would be fine. In C you must declare variables first in the code block.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102
    Thank you very much. I figured I was ignorant of something with C.
    WebSnozz-
    Cats have no butt cheeks.
    If one farted, then it would make a flute noise.

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    You can comment out code that may be broken.

    Code:
    #include <stdio.h>
    #include <ctypes.h>
    #include <conio.h>
    #include "my_menu.h"
    
    int change_menu(menu *m) {
         m->title = "erroneous code";
         return m.status; //also incorrect
    }
    
    int test_file(const char *filename) {
         strcpy(filename, "help.txt");
         return -1;
    }
    
    int main(void) {
        menu m;
        change_menu(&m);
        return 0;
    }
    There are several examples of errors here so rather than delete functions you can do this.

    Code:
    #include <stdio.h>
    #include <ctypes.h>
    //#include <conio.h>
    //#include "my_menu.h"
    
    /****comment out evil functions****
    int change_menu(menu *m) {
         m->title = "erroneous code";
         return m.status; //also incorrect
    }
    
    int test_file(const char *filename) {
         strcpy(filename, "help.txt");
         return -1;
    }
    ****end of comment****/
    
    int main(void) {
    //    menu m;
    //    change_menu(&m);
        return 0;
    }

  5. #5
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    the error is on line 11, check that line
    cuz, i don't think it was posted...

    if that was all the program then...
    there is a lot of reasons why it won't work.
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  6. #6
    Registered User WebSnozz's Avatar
    Join Date
    Oct 2001
    Posts
    102
    I understand commenting but didn't think yall would appreciate me posting the hundred or so lines of code that were in the project that I had already commented out.

    Line 11 is there. It's the 11th line, with the comment.
    PHP Code:
    unsigned long *testippntr=&testip;//the first error refers to this line 
    I had fixed the problem by moving the declaration up but was afraid something was wrong with the line preceding sinze it seemed it wasn't seeing the ';'. I didn't know that it was a rule of C that declerations come before executions.
    WebSnozz-
    Cats have no butt cheeks.
    If one farted, then it would make a flute noise.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C and C++ compile speed
    By swgh in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-02-2007, 02:37 PM
  2. Compile as you type
    By Rocketmagnet in forum A Brief History of Cprogramming.com
    Replies: 33
    Last Post: 12-07-2006, 01:36 PM
  3. How to compile mfc libs from platform sdk
    By tjcbs in forum Windows Programming
    Replies: 6
    Last Post: 11-19-2006, 08:20 AM
  4. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 09:05 PM
  5. How can I compile C or C++ with Visual Studio .NET?
    By Dakkon in forum C Programming
    Replies: 8
    Last Post: 02-11-2003, 02:58 PM