Visibility of variables not declared in the header file (GNU C).
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Visibility of variables not declared in the header file (GNU C).
Hi: I have three files: usbdrvasm.S, usbdrv.c and usbdrv.h. usbdrvasm.S uses the usbInputBuf variable. The only place where this variable is declared is usbdrv.c. Now, usbdrvasm.S includes the usbdrv.h:
Code:
#include "usbdrv.h"
But usbInputBuf is nowhere to be seen in usbdrv.h. How can usbdrvasm.S see it?
EDIT: maybe it is resolved at linking time? But there is no extern declaration in usbdrvasm.S.
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "usbdrv.h"
/*
General Description:
This module implements the C-part of the USB driver. See usbdrv.h for a
documentation of the entire driver.
*/
/* ------------------------------------------------------------------------- */
/* raw USB registers / interface to assembler code: */
/* usbRxBuf MUST be in 1 byte addressable range (because usbInputBuf is only 1 byte) */
static char usbRxBuf[2][USB_BUFSIZE];/* raw RX buffer: PID, 8 bytes data, 2 bytes CRC */
uchar usbDeviceId; /* assigned during enumeration, defaults to 0 */
uchar usbInputBuf; /* ptr to raw buffer used for receiving */
uchar usbAppBuf; /* ptr to raw buffer passed to app for processing */
The only places in usbdrvasm.S where the variable is used are:
Then it would seem that the writers of that module did not intend to make that variable externally visible ... or, at least, they did not consider it "safe" to let other modules refer to it willy-nilly. They wanted it to be private, insofar as "C" supports such a notion.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.