@neel1311 wrote:
In the generated code in main.c file, there are variables that are declared as "private variables" by the software, such as "ADC_HandleTypeDef hadc1"; "TIM_HandleTypeDef htim1". !
Please show that code.
See: How to insert source code.
In the C language, variables (and functions) defined at file scope are public unless specifically qualified as static
EDIT:
You mean stuff like this:
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stm32g0xx_nucleo_32.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;
That comment is actually misleading.
As noted above, the hadc1 definition there is public - because it is not qualified as static.
So, as @Karl Yamashita said, you can provide your own extern declarations anywhere you want to use it - either in your own header file, or in a USER section of one of the auto-generated headers.
If you configure the project to generate separate .c & .h files for peripheral initialisation:

The extern declarations for the peripheral handles will be in the generated headers; eg,
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
extern ADC_HandleTypeDef hadc;
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */