Jump to content

Enabling all warnings while compilation


Recommended Posts

Hi,

I am new to SystemC programming. I started implementing from scratch. My intention is to develop TLM models depicting different processor subsystems.  I have two questions regarding compilation.

1. Can we use gcc or we should use g++ only?

2. I want to enable all the possible warnings for debug purposes. I am using the following switches. I will appreciate if you please comment regarding the switches.

 

-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror -Wno-unused

 

Thanks in advance.

 

Best regards

SC

Link to comment
Share on other sites

Hello @Saikat,

Regarding your questions.

6 hours ago, Saikat said:

1. Can we use gcc or we should use g++ only?

Since SystemC is written in C++, g++ should be the default.

6 hours ago, Saikat said:

2. I want to enable all the possible warnings for debug purposes. I am using the following switches. I will appreciate if you please comment regarding the switches.

Regarding compiler warning the ones mentioned in your post:

6 hours ago, Saikat said:

-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror -Wno-unused

Seems a good enough list for now. I would prefer you going through your compiler manual to figure which ones you might need.

But, as my personal preference I usually prefer to build my code with various compilers and on various platforms to get the best possible platforms compatible code.

It is very easy the write a code which might end up being platform/compiler dependent.

Better to stick with standard C++ language compliance to get the most out of your code.

Regards,

Ameya Vikram Singh

Link to comment
Share on other sites

6 hours ago, AmeyaVS said:

Hello @Saikat,

Regarding your questions.

Since SystemC is written in C++, g++ should be the default.

Regarding compiler warning the ones mentioned in your post:

Seems a good enough list for now. I would prefer you going through your compiler manual to figure which ones you might need.

But, as my personal preference I usually prefer to build my code with various compilers and on various platforms to get the best possible platforms compatible code.

It is very easy the write a code which might end up being platform/compiler dependent.

Better to stick with standard C++ language compliance to get the most out of your code.

Regards,

Ameya Vikram Singh

Thanks Ameya!! Being from a very different background it helps really as of now.

Link to comment
Share on other sites

Be aware that SystemC itself is compiled with g++/clang++ using the following options "-Wall -Wextra -no-unused-parameter -W-no-unused-variable". Any additional warning options might trigger additional warnings inside the SystemC headers. You may therefore point g++ to the headers using "-isystem" instead of "-I".

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...