extern static variable
Hi i have a problem using the extern definition with a struct
The struct is defined as following from file diffServLinux.h struct diffstat{ unsigned long int ifindex; unsigned long int ifdirection; char name[20]; unsigned long int level; unsigned long int handle_major; unsigned long int handle_minor; .......... }; File monitor.c /*Strores values in the variables */ #include "diffServLinux.h" struct diffstat ds_stats[10]; ds_stats[1].ifindex=20; File logical.c /*Wants to see the values in the ds_stats struct */ I have tried using the extern statement extern struct diffstat ds_stats[10]; I compile it using gcc -o programme monitor.c logical.c but this returns the error logical.c: At top level: logical.c:2: error: storage size of `ds_stats' isn't known The compiler says that perhaps cant understand the internal structure of the ds_stats I have tried also to include the diffServLinux.h in the logical.c but then the compiler starts complaining about a bunch of redefinitions Dont know what to do now... Plz help |
diffServLinux.h:
Code:
#ifndef DIFFSERVLINUX_H Code:
#ifndef GLOBALS_H Code:
#include "globals.h" Code:
#include <string.h> /* memset() */ Code:
CC = gcc |
Thx a lot cool :)
THHHXXX |
1 more question.. Where have u learned all this stuff?
|
Reading a lot of books (not web tutorials, but good books), asking on/reading the programming groups (comp.lang.c, comp.lang.c++ mostly, but also groups dealing with a specific platform) on usenet. Later in life I've also taken courses in programming at the university. I started with C++ ten years ago, but the first five years or so I had long periods when I did no programming at all (unfortunately).
|
What do u mean by programming groups....
I am looking for a place that i can ask about c... Sometimes i think that this place isnt the most appropriate ... (linux forums) |
Well, it seems you need to read up on what usenet is. If you google for usenet you should find a lot of information. Many ISP:s (Internet Service Providers) have a usenet server. You can configure most mail clients to allow you to read (and post on) usenet groups if your ISP has a news server. There are also programs that are exclusively for reading newsgroups. If your ISP doesn't have a news server, google provides a http-based access to it that's free. Before, google groups lagged behind several hours so it was inconvenient to use, but that's not the case today.
Head over to: http://groups.google.com/group/comp.lang.c Keep in mind, though, that comp.lang.c only deals with the C language. Anything that's platform specific is off-topic for the group. But there are groups for developing on linux and other operating systems. If your question is pure C (like the one in this thread), ask in comp.lang.c, if it concerns libraries, api:s etc that's not part of the core language but provided by a specific operating system, ask in a group/forum dedicated to developing on that platform. |
Hi -
In addition to the Stevens book, I'd also get a copy of Kernighan and Ritchie. It's the single best reference for these kinds of questions in the entire world. It's also one of the best "computer books" ever written. No kidding! And you can probably buy a copy on Amazon for around $20.00: Kernighan & Ritchie: The C Programming Language: http://www.amazon.com/exec/obidos/tg...=UTF8&v=glance Unix Network Programming, 3rd Edition: http://www.amazon.com/exec/obidos/tg...glance&s=books |
Thx hivemind about your second reply... I have subscribed to google groups for c language.. but still i cant find any subgroup for linux c ...
|
Maybe comp.unix.programmer (many API:s and libraries work the same across unix and linux) and comp.os.linux.development.apps? I'm sure there are others. linuxquestions is fine for platform specific questions, but if you really need help from C experts comp.lang.c is the best.
|
All times are GMT -5. The time now is 08:09 PM. |