Open kcvinker opened 9 months ago
Can you check if this looks better with 0.5.4?
@lerno , Sure.
Edit: What happened ? I couldn't find the download files for 0.5.4.
@lerno, This is the error I see.
1: module std::math::random;
2:
3: interface Random
^^^^^^
(C:/Compilers/C3/lib/std/math/math_random.c3:3:11) Error: 'Random' would shadow a previous declaration.
1: module std::math::random;
2:
3: interface Random
^^^^^^
(C:/Compilers/C3/lib/std/math/math.random.c3:3:11) Note: The previous use of 'Random' was here.
What did you do to get that error?
@lerno, The one and only use for math library in my code is this.
import std::math;
macro clip(x) {
return math::clamp(x, 0, 255);
}
If you just compile a file, do you get the same error?
Because somehow you've managed to insert the same symbol twice, and I just can't see how that could happen. But apparently it does, so I'm trying to find out how...
If you just compile a file, do you get the same error?
Let me try that.
@lerno I just tested with sample dll code. This time, I didn't used any math lib code. See this is my source code.
module dlltest;
fn void sample(int x) @export("MySampleFunc")
{
int b = x + 2;
}
fn int testFunc(int y) @export("My_test_func")
{
return y + 8;
}
And this is the start position of the error message.
c3c build dlltest
1: module std::math::random;
2:
3: interface Random
^^^^^^
(C:/Compilers/C3/lib/std/math/math_random.c3:3:11) Error: 'Random' would shadow a previous declaration.
1: module std::math::random;
2:
3: interface Random
^^^^^^
(C:/Compilers/C3/lib/std/math/math.random.c3:3:11) Note: The previous use of 'Random' was here.
Can you show me the project file?
@lerno Here is my project.json
{
// language version of C3
"langrev": "1",
// warnings used for all targets
"warnings": [ "no-unused" ],
// directories where C3 library files may be found
"dependency-search-paths": [],
// libraries to use for all targets
"dependencies": [ ],
"linker-search-paths": [],
"linked-libraries": [],
// authors, optionally with email
"authors": [ "kcvinker" ],
// Version using semantic versioning
"version": "0.1.0",
// sources compiled for all targets
"sources": [ "./**"],
// Targets
"targets": {
"dlltest": {
// executable or library
"type": "dynamic-lib"
// additional libraries, sources
// and overrides of global settings here
},
},
// Debug information, may be 'none', 'full' and 'line-tables'
"debug-info": "full",
// Architecture and OS target:
"target": "windows-x64",
// The size of the symtab, which limits the amount
// of symbols that can be used. Should usually not
// be changed.
//"symtab": 4194304,
// "none", "pic", "PIC", "pie", "PIE"
"reloc": "none",
// Trap on signed and unsigned integer wrapping
// for testing
"trap-on-wrap": false,
// Use / don't use soft float, value is otherwise target default
"soft-float": false,
// Vector settings on x86: none/native/mmx/sse/avx/avx512
"x86vec": "sse",
// CPU name, used for optimizations in the LLVM backend
"cpu": "generic",
// Output location, relative to project file
"output": "./build",
// C compiler if the project also compiles c sources
// defaults to 'cc'
"cc": "cc",
// c sources if the project also compiles c sources
// relative to the project file
"c-sources": [
"csource/**"
]
}
Hmm.. that one looks normal. What if you just compile a single file with c3c.exe compile foo.c3
?
Let me check that.
@lerno Same result. This is source.
import std::io;
fn void main()
{
io::println("testing version 0.5.4");
}
And this is result
λ c3c compile foo.c3
1: module std::math::random;
2:
3: interface Random
^^^^^^
(C:/Compilers/C3/lib/std/math/math_random.c3:3:11) Error: 'Random' would shadow a previous declaration.
1: module std::math::random;
2:
3: interface Random
^^^^^^
(C:/Compilers/C3/lib/std/math/math.random.c3:3:11) Note: The previous use of 'Random' was here.
11: fn void next_bytes(char[] buffer);
12: }
13:
14: macro bool is_random(random) => $assignable(random, Random*);
^^^^^^^^^
(C:/Compilers/C3/lib/std/math/math_random.c3:14:12) Error: 'is_random' would shadow a previous declaration.
@lerno I think this issue is not caused by c3. I think I can do something. Let me try.
@lerno, Yeah, it was a mistake from my side and I solved it. What caused the issue ---> I am using a python script to update the compilers I use in my projects. This script will download the latest binaries from github and extract them. Then it will remove the old files and paste the new files in respective directories. Last day, when you told me to check the version 0.5.4, I ran this script and at that time newest binaries where not uploaded to the repo's asset section. So my script ran and showed me an error message that there is no new files in the repo. After 2 hours, you uploaded the files and I ran this script again. This time everything worked smoothly and I got the version 0.5.4 installed. But something strange were happened when last time the script ran. I don't know what was it. But now, I copy pasted the new binaries with my hand, everything works smoothly.
I wonder how it can be reproduced. Because that should never really be possible, incorrect libraries or not....
I think we can reproduce. Steps
Ok, I know why now. Look at the file names:
C:/Compilers/C3/lib/std/math/math_random.c3:3:11) Error:
C:/Compilers/C3/lib/std/math/math.random.c3:3:11) Note
Do you see the subtle difference? math_random.c3
and math.random.c3
. Both ended up in lib/std/math because your just copied updated files in your script, you didn't delete the old stdlib files. So when names change, this happens.
That's a clever observation. Your attention to detail and problem-solving skills are really impressive.
Just ordinary debugging.
can this issue be closed then?
@goyalyashpal, Actually, the header file generation is still the same. It is not fixed yet.
@kcvinker this is odd, can you show me some sample of the output. Because this was changed.
@lerno This is my c3c version
C3 Compiler Version (alpha): 0.5.4
Installed directory: C:/Compilers/C3/
LLVM version: 16.0.2
LLVM default target: x86_64-pc-windows-msvc
And this is the types generated by c3c in the header file.
typedef struct pyc3.Button__ pyc3.Button;
typedef struct pyc3.Control__ pyc3.Control;
typedef enum pyc3.ControlType__ pyc3.ControlType;
enum pyc3.ControlType__
{
pyc3.ControlType_NONE,
pyc3.ControlType_BUTTON,
pyc3.ControlType_CALENDAR,
pyc3.ControlType_CHECK_BOX,
pyc3.ControlType_COMBO_BOX,
pyc3.ControlType_DATE_TIME_PICKER,
pyc3.ControlType_GROUP_BOX,
pyc3.ControlType_LABEL,
pyc3.ControlType_LIST_BOX,
pyc3.ControlType_LIST_VIEW,
pyc3.ControlType_NUM_PICKER,
pyc3.ControlType_PROGRESS_BAR,
pyc3.ControlType_RADIO_BUTTON,
pyc3.ControlType_TEXT_BOX,
pyc3.ControlType_TRACK_BAR,
pyc3.ControlType_TREE_VIEW,
};
@kcvinker You can use @export
on your types to name them correctly.
@cbuttner Let me try that. Thanks.
When creating dlls with c3c, it is a nice feature to create C headers automatically. But this header file is not working in c compilers like MSVC. Please improve this feature so that we use this header files straight in MSVC. Now type names are showing with module name like
abc.type
.