Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22028

GCC gives "undefined reference" error to extern variable [closed]

$
0
0

I know this question has been asked several times, but none of the solutions worked for me. That's why I created a new question.

I'm trying to add the custom charging driver ThunderCharge to my kernel. The commits for the same can be found here: https://github.com/androbada525/Elindir-Kernel/commits/pie-oc-jack-fix

While compiling, I'm getting several "undefined reference to custom_ac_current" errors from a single file drivers/power/qpnp-smbcharger.c. The complete error log can be found here: https://del.dog/elindir-log-1.txt

Here is a relevant snippet:

In function `smbchg_is_parallel_usb_ok':
/home/krittinkalra/Elindir-Kernel/drivers/power/qpnp-smbcharger.c:2204: 
undefined reference to `custom_ac_current'

The header file - thundercharge_control.h - where the variable custom_ac_current has been declared is included in the file. The variable has been declared using the extern macro in thundercharge_control.h and is defined in thundercharge_control.c.

Here is the header file:

#ifndef __THUNDERCHARGE_CONTROL_H__
#define __THUNDERCHARGE_CONTROL_H__
#define DEFAULT_USB_CURRENT 900
extern int custom_ac_current;
extern int custom_usb_current;
extern int mswitch;
#endif

Here are some important bits from thundercharge_control.c:

#include "thundercharge_control.h"
.
.
#define AC_CURRENT          2000
#define USB_CURRENT         900
#define MAX_VBUS_CURRENT    2400
#define THUNDERCHARGE       "thundercharge"

int mswitch = ENABLED;
int custom_ac_current = AC_CURRENT;
int custom_usb_current = USB_CURRENT;
.
.

The portions of qpnp-smbcharger.c related to the error snippet is as follows:

#include "thundercharge_control.h"
.
.
#define PARALLEL_CHG_THRESHOLD_CURRENT  custom_ac_current
.
.
if (fcc_voter_id != ESR_PULSE_FCC_VOTER
            && fcc_ma < PARALLEL_CHG_THRESHOLD_CURRENT) {
        pr_smb(PR_STATUS, "FCC %d lower than %d\n",
            fcc_ma,
            PARALLEL_CHG_THRESHOLD_CURRENT);
        return false;
    }
.
.

I can't make out why I'm getting the undefined reference errors even though the definition of the corresponding variable is already included.

Here are links to the files in question:

qpnp-smbcharger.c:https://github.com/androbada525/Elindir-Kernel/blob/pie-oc-jack-fix/drivers/power/qpnp-smbcharger.c

thundercharge_control.h:https://github.com/androbada525/Elindir-Kernel/blob/pie-oc-jack-fix/drivers/power/thundercharge_control.h

thundercharge_control.c:https://github.com/androbada525/Elindir-Kernel/blob/pie-oc-jack-fix/drivers/power/thundercharge_control.c

Here is the kernel source from which the ThunderCharge commits were sourced: https://github.com/varunchitre15/thunderzap_tomato/commits/cm-13.0


Viewing all articles
Browse latest Browse all 22028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>