Skip to content

Allow the core to detect the used compiler version - #108

Open
alessandropellegrini wants to merge 1 commit into
developfrom
compiler-version
Open

Allow the core to detect the used compiler version#108
alessandropellegrini wants to merge 1 commit into
developfrom
compiler-version

Conversation

@alessandropellegrini

Copy link
Copy Markdown
Member

rootsim-cc will inject in the model a variable allowing the core to detect what version of the compiler was used to compile the code.

rootsim-cc will inject in the model a variable allowing the
core to detect what version of the compiler was used to
compile the code.

Signed-off-by: Alessandro Pellegrini <a.pellegrini@ing.uniroma2.it>
@github-actions

Copy link
Copy Markdown

Documentation coverage is 82.6% 👍

Classes    : 100.0% (1/1)
Defines    :  78.6% (103/131)
Enum Values:  88.2% (45/51)
Enums      :  55.6% (5/9)
Files      :  93.8% (61/65)
Functions  :  79.9% (231/289)
Namespaces :   0.0% (0/3)
Pages      : 100.0% (1/1)
Structs    :  94.1% (16/17)
Typedefs   : 100.0% (11/11)
Variables  :  85.1% (120/141)
-----------------------------------
Total      :  82.6% (594/719)

@codecov

codecov Bot commented Oct 25, 2023

Copy link
Copy Markdown

Codecov Report

Merging #108 (d697b58) into develop (31001ee) will decrease coverage by 0.55%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop     #108      +/-   ##
===========================================
- Coverage    86.77%   86.22%   -0.55%     
===========================================
  Files           40       39       -1     
  Lines         1459     1365      -94     
  Branches        38       37       -1     
===========================================
- Hits          1266     1177      -89     
+ Misses         178      173       -5     
  Partials        15       15              

see 4 files with indirect coverage changes

Comment thread src/core/core.c
* SPDX-License-Identifier: GPL-3.0-only
*/
#include <core/core.h>
#include <core/compiler.h>

Check warning

Code scanning / Cppcheck (reported by Codacy)

Include file: <core/compiler.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Include file: <core/compiler.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
Comment thread src/core/compiler.h
*/
#pragma once

#include <stdint.h>

Check warning

Code scanning / Cppcheck (reported by Codacy)

Include file: <stdint.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Include file: <stdint.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
Comment thread src/core/compiler.h
#include <stdint.h>

/// The version of the compiler used to generate a model
uint32_t __attribute__((weak)) rootsim_compiler_version = 0;

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file

misra violation 804 with no text in the supplied rule-texts-file

@Piccions Piccions left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments, thanks for your work!

Comment thread src/core/compiler.h
uint32_t __attribute__((weak)) rootsim_compiler_version = 0;

/// This macro allows to convert a major, minor and patch version into a single uint32_t
#define ROOTSIM_COMPILER_VERSION(a,b,c) (uint32_t)(((a) << 16) + ((b) << 8) + (c))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we used an array of three unsigned chars to represent the version, we wouldn't need a macro to set it (or to read it, even if the corresponding macros haven't been defined)

Comment thread src/core/compiler.h
#include <stdint.h>

/// The version of the compiler used to generate a model
uint32_t __attribute__((weak)) rootsim_compiler_version = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could declare this variable here rather than defining it inside this header, and define it as a weak symbol inside core.c

@Piccions

Piccions commented Jun 2, 2025

Copy link
Copy Markdown
Contributor

Do we drop this PR or do we want this feature to be merged?

@alessandropellegrini

Copy link
Copy Markdown
Member Author

Let's keep this open. I have a plan to slightly repurpose this stuff, even though the compiler is dead code now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants