Thread: headerfiles how define product wjde structurers?

  1. #1
    Registered User
    Join Date
    Dec 2013
    Posts
    46

    Question headerfiles how define product wjde structurers?

    headerfiles how define program project wide structurers? and how header file wide (i mean applies only file where they defined) structures? i know how struces are defined but my sources dont ansver this.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Not sure what you are talking about. Are you referring to how the Windows API has "wide" and "narrow" interfaces and structures?

    gg

  3. #3
    Registered User
    Join Date
    Dec 2013
    Posts
    46
    Quote Originally Posted by Codeplug View Post
    Not sure what you are talking about. Are you referring to how the Windows API has "wide" and "narrow" interfaces and structures?

    gg
    project is program what i develop.first way all header file defined structures,and variables i want used in whole program. and second way header file has own structures which dont show elsewhere. Actually i think now heared file structures,and variables show all to main code because os related header files work this way.

    ps. no i dont develop Windows actually much better multitasking (before has multitasking before windows) graphical operating system which latest version is 4.1 and its runs PowerPC based computers today.

  4. #4

  5. #5
    Registered User
    Join Date
    Dec 2013
    Posts
    46
    Quote Originally Posted by Codeplug View Post
    Well, definitions go in header files, and declarations go in your translation units (.c files).

    Perhaps this will help:
    What's the difference between declaring and defining in C and C++ - Cprogramming.com
    https://www.google.com/search?q=C%20header%20tutorial

    gg
    Whicj means i must declare in main code all functions what headers have? now i dont understand why os functions,and ansi c functions works without this.
    ps. before windows in my comment means Windows which mean Operating system not windows what all modern? graphical operating systems uses.

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> now i dont understand why os functions,and ansi c functions works without this.
    Either the compiler automatically links in the appropriate libraries, or the needed libraries are specified on the command line.

    You can achieve the same thing generically using object files, static libraries, or dynamic libraries.

    src.h
    src.c -> src.obj
    main.c includes src.h and links with src.obj

    gg

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,410
    Quote Originally Posted by Codeplug
    Well, definitions go in header files, and declarations go in your translation units (.c files).
    It is actually the opposite, i.e., extern variable and function declarations (that are not also definitions) typically go in header files whereas their definitions go in the source files. A struct definition would also go in a header file; the C standard regards that as a declaration of a structure type that defines the structure content. A translation unit is actually the source file + the included (typically header) files after preprocessing.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Codeplug View Post
    Well, definitions go in header files, and declarations go in your translation units (.c files).
    Other way 'round.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  9. #9
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    What's worse is that I glanced over Alex's article first to ensure I didn't get em reversed.

    I was gifted dyslexia with to keep you own your toes

    gg <-- reversed

  10. #10
    Registered User
    Join Date
    May 2009
    Posts
    4,138
    Quote Originally Posted by Codeplug View Post
    What's worse is that I glanced over Alex's article first to ensure I didn't get em reversed.

    I was gifted dyslexia with to keep you own your toes

    gg <-- reversed
    You might try this font; and give feedback on whether it helps.

    Christian Boer’s Dyslexie is a typeface for dyslexics.

    Edit: I just read about it on a ebook forum I read.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  11. #11
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,398
    Whether a structure is available "project wide" is up to you. If the structure is defined in a header file, then its definition is available in any other file which includes that header file. If you want to absolutely ensure that a structure can't be used outside of one specific module, then you can declare it in the .c or .cpp file where it will be used.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Define new function as product of two functions
    By freechus9 in forum C Programming
    Replies: 5
    Last Post: 11-05-2011, 09:19 PM
  2. Including default headerfiles in custom headerfiles
    By Sentral in forum C++ Programming
    Replies: 7
    Last Post: 02-18-2006, 09:42 AM
  3. C headerfiles into C++
    By jaylc185 in forum C++ Programming
    Replies: 4
    Last Post: 05-20-2005, 02:47 PM
  4. Dot Product.......Help
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 03-07-2003, 08:49 AM