Definition, Assignment, Declaration

This is a discussion on Definition, Assignment, Declaration within the C Programming forums, part of the General Programming Boards category; I know that the first is a declaration, and the second is an assignment: Code: int a; a = 1; ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    31

    Definition, Assignment, Declaration

    I know that the first is a declaration, and the second is an assignment:
    Code:
    int a;
    a = 1;
    What does it mean by "if an identifier is defined"? Has it been declared and assigned or just declared?

    Question is regarding macro directives: #ifdef and defined

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Perhaps give an example of what you are having issues with, unfortunately C has "overloaded definitions" of 'define'.
    http://c-faq.com/decl/decldef.html

    [edit]
    Code:
    #include <stdio.h>
    
    #define FOO /* comment this out, compile, and compare */
    #if defined FOO
    const char text[] = "foo";
    #else
    const char text[] = "bar";
    #endif
    
    int main()
    {
       puts(text);
       return 0;
    }
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. declaration or definition
    By BEN10 in forum C Programming
    Replies: 5
    Last Post: 07-19-2008, 07:50 PM
  2. My first game
    By homeyg in forum Game Programming
    Replies: 20
    Last Post: 12-22-2004, 04:25 PM
  3. Declaration vrs Definition
    By curlious in forum C++ Programming
    Replies: 1
    Last Post: 09-03-2004, 07:13 PM
  4. please help me
    By insane in forum Game Programming
    Replies: 8
    Last Post: 05-12-2003, 12:40 AM
  5. Templated function (declaration and definition)
    By Eibro in forum C++ Programming
    Replies: 2
    Last Post: 03-11-2003, 07:07 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21