Programing app Gtk in plasma using C VSCODE Compile errors

Of course, that’s what makes it so great! :slight_smile:

@Data, if you want to properly learn the modern C language, a great book is Modern C by Jens Gustedt. I’m guessing (no experience in this, of course!!!) that one could could find a pdf of it somewhere online, if one were to look hard enough, but I wouldn’t recommend that, of course, because that would be against the law and I would never recommend doing things against the law, as that would be against the law, too. The secret police agent assigned to my case knows this very well, don’t you? :sweat_smile:

Keep in mind, I’m not talking about C++, that’s something completely different. The two should never be confused and mixed – in fact, if your program is both in C and C++, the compilation units should be monolingual and separately compiled to object code and only then linked together into the final binary executable. Even though you can often get away with #include-ing C code into a cpp file, you should be very careful of that. The languages are not the same, the same code can compile in both languages fine but give different results at runtime, and undefined behaviour lurks behind every corner when you do that.

1 Like

Hi
MM I wondered if it was C++ or C, the files ‘his’ end in .c and others .h

Oh well back to the drawing board if it’s C++ that’s different still. Ile have to
search for different YouTube videos to follow.

Data

if you already know how to program in python, why not learn GTK with python?

https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html#simple-example

Hi
@pycrk The original one is written in C++ or C see the previous comment
so to work it out I’d rather fit in with what is before it’s a big program.

Data

1 Like

It is possible that it is a mix of C and C++. .c usually indicates C and .cpp usually indicates C++

MM well, it’s .c so that’s C then, don’t know what .h files are then.
Investigating. Latter.

it’s better, as @dalto suggested, that you learn c first before going on to GTK. otherwise you will waste time and not learn it properly.

.h file is a header file, it can contain variables, constants and functions used by other files within a programming project. In .h files, frequently used functions can only be written once and can be referenced by other source files if necessary.

The .h files are headers

I would just warn again that C isn’t like Python. You can’t muddle through it.

1 Like

You may want to learn that before you start programming in C, it’s a rather important subject.

What’s the worst that can happen? Unless it is some sensitive application where security matters, it should be fine.

Muddling should be encouraged (just not in production code, please!), that’s a good way to learn stuff, especially when you witness it freezing your OS :joy: Seriously, it’s a good idea to enable Magic SysRq key, just in case. But, in general, memory management in C is often mystified and made to look like a bigger deal that it actually is.

But yes, C should (also) be learnt in a structured way. There are many potential pitfalls and in production code, one should be mindful not to have crashes, security vulnerabilities and damaging side effects.

1 Like

‘Kresimir’
“You may want to learn that before you start”
I learn by example, I will study what’s there both in written form and by gaining knowledge by watching videos on the subject via YouTube.
"
‘Kresimir’
“What’s the worst that can happen? Unless it is some sensitive application where security matters, it should be fine.”
Its just picks the names of files paths and passes that information on to a program so that the file can be executed/run.

Security, pah, no it’s not I appreciate all the information that’s being passed on, I will have to delve more in-depth into the subject though.
Thanks

Data

Perhaps you and I don’t have the same definition of “muddle”.

What I have seen happen many times is that people try to learn C by making random changes and since the results are often unintuitive, they become increasingly mystified before deciding it is “too hard” and give up in failure.

My point wasn’t that you need to become a C expert or anything, but before trying to modify a GTK program, there is some foundational knowledge you need to understand:

  • You need to understand the basic syntax of the language. If you don’t know what those curly braces do you aren’t going to be able to get anywhere.
  • You need to understand the basics of how variables and memory management work. This is especially true if you are coming from something like python where it works radically differently. For example, you need to realize how arrays and array sizes work.
  • You need to understand that | and || are different and which one you should probably use in comparisons.
  • You need to recognize that C will let you do almost anything syntactically even if it would result in something broken. Modern C compilers are a lot better about this than they used to be but it is still there. i.e. You can’t do int a[5]; int b[5]; a+=b; anymore but you can still do char* animal; animal="monkey"
  • You need to understand what pointers are and some basics about how they work because they are used by GTK.

That is exactly my point. C is actually a very simple language. It isn’t hard to learn. But if you just jump in without any basic knowledge at all, memory management seems like a mystical art. You won’t even know when you need to use it and when you don’t.

Jumping into C with no understanding of the basics will make it harder, not easier.

3 Likes